Skip to content

Commit

Permalink
reduce ocean jittering in RSS
Browse files Browse the repository at this point in the history
  • Loading branch information
LGhassen committed May 17, 2021
1 parent 3b14c36 commit 76e6f08
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
16 changes: 12 additions & 4 deletions scatterer/Effects/Proland/Ocean/OceanCameraUpdateHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,18 @@ public void updateCameraSpecificUniforms (Material oceanMaterial, Camera inCamer
ctol1.m10, ctol1.m11, ctol1.m12, ctol1.m13,
ctol1.m20, ctol1.m21, ctol1.m22, ctol1.m23,
ctol1.m30, ctol1.m31, ctol1.m32, ctol1.m33);

Vector3d translation = oceanNode.m_manager.parentLocalTransform.position;



Vector3d translation;

if (HighLogic.LoadedScene == GameScenes.SPACECENTER)
{
translation = oceanNode.m_manager.parentLocalTransform.position; //have to use this in space center or get the tsunami bug
}
else
{
translation = oceanNode.m_manager.parentCelestialBody.position; //more precise, especially with RSS, but breaks a bit in KSC
}

Matrix4x4d worldToLocal = new Matrix4x4d(1, 0, 0, -translation.x,
0, 1, 0, -translation.y,
0, 0, 1, -translation.z,
Expand Down
4 changes: 2 additions & 2 deletions scatterer/Scatterer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using UnityEngine;
using UnityEngine.Rendering;

[assembly:AssemblyVersion("0.0769")]
[assembly:AssemblyVersion("0.0770")]
namespace scatterer
{
[KSPAddon(KSPAddon.Startup.EveryScene, false)]
Expand Down Expand Up @@ -54,7 +54,7 @@ public class Scatterer: MonoBehaviour
bool coreInitiated = false;
public bool isActive = false;
public bool unifiedCameraMode = false;
public string versionNumber = "0.0769 dev";
public string versionNumber = "0.0770";

public List<GenericAntiAliasing> antiAliasingScripts = new List<GenericAntiAliasing>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,34 @@ float2 ds_div (float2 dsa, float2 dsb) {
dsc.y = minus_frc(s2, minus_frc(dsc.x, s1));

return dsc;
}


float2 ds_sqrt (float2 dsa) {
float2 dsb;

float t1, t2, t3;
float2 f, s0, s1;

if (dsa.x == 0.0)
{
return float2(0.0,0.0);
}

t1 = div_frc(1.0, sqrt(dsa.x));
t2 = times_frc(dsa.x, t1);

s0 = ds_mul(ds_set(t2),ds_set(t2));
s1 = ds_sub(dsa, s0);

t3 = times_frc(0.5, times_frc(s1.x,t1));

s0.x = t2;
s0.y = 0.0;
s1.x = t3;
s1.y = 0.0;

dsb = ds_add(s0, s1);

return dsb;
}

0 comments on commit 76e6f08

Please sign in to comment.