Tweak Stardust Placement

Quick commit before I break everything by upgrading Unity
Modified vertical placement code for stardust particles
This commit is contained in:
Reinier Vens 2022-07-17 21:51:51 +01:00
commit ae79a152e9
9 changed files with 26 additions and 19 deletions

BIN
Assets/Resources/Settings.asset (Stored with Git LFS)

Binary file not shown.

View file

@ -16187,8 +16187,8 @@ MonoBehaviour:
MaximumSize: 0.75
Spacing: 6
Ceiling: -250
Floor: -25
HeightExponent: 1000000
Floor: -20
HeightExponent: 2
NebulaSurfaceHeight: {fileID: 8400000, guid: 2fc21a9d3e9647948b56e384cd9378b3, type: 2}
NebulaPatchHeight: {fileID: 8400000, guid: c618a6b20b3c7394590c59a9fa467e86, type: 2}
NebulaPatch: {fileID: 8400000, guid: 06ec5ef8a5830fc44b1ac1a6e123add5, type: 2}
@ -30714,7 +30714,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
downSample: 0
quality: 1
quality: 2
cloudShader: {fileID: 4800000, guid: 84e97169589c5e94e8521fe4deb2e3f8, type: 3}
--- !u!20 &2115559089
Camera:

View file

@ -866,7 +866,7 @@ MonoBehaviour:
Spacing: 6
Ceiling: -0.1
Floor: -30
HeightExponent: 200000
HeightExponent: 3
NebulaSurfaceHeight: {fileID: 8400000, guid: 2fc21a9d3e9647948b56e384cd9378b3, type: 2}
NebulaPatchHeight: {fileID: 8400000, guid: c618a6b20b3c7394590c59a9fa467e86, type: 2}
NebulaPatch: {fileID: 8400000, guid: 06ec5ef8a5830fc44b1ac1a6e123add5, type: 2}

View file

@ -123,9 +123,9 @@ void UpdateParticles(uint3 id : SV_DispatchThreadID, int3 groupID : SV_GroupThre
y * spacing + yt * spacing + perlinNoise1D(RandomValue()*1024)*spacing);
const float2 puv = getUV(particles[id.x].position.xz);
const float gravHeight = -tex2Dlod(_NebulaSurfaceHeight, float4(puv, 0, 0)).x + _NebulaFloorOffset;
const float headroom = ceilingHeight - gravHeight;
const float headroom = clamp(ceilingHeight - gravHeight, 25, 150);
particles[id.x].position.y = gravHeight + floorHeight + headroom *
pow(RandomValue(), max(1, heightExponent/(headroom*headroom))) +
pow(RandomValue(), heightExponent) +
perlinNoise1D(RandomValue()*1024)*spacing/2;
float noise;
const float3 flowVec = flow(particles[id.x].position, noise);

View file

@ -16,7 +16,7 @@ float DeltaTime;
// Adjustment
int2 Delta;
float Fade;
float Damping;
// External force
float2 ForceOrigin;
@ -73,7 +73,7 @@ void Adjust(uint2 tid : SV_DispatchThreadID)
if(any(prevUV<0)||any(prevUV>1))
W_out[tid] = f.xz;
else W_out[tid] = lerp(U_in.SampleLevel(samplerU_in, prevUV, 0), f.xz, Fade);
else W_out[tid] = lerp(U_in.SampleLevel(samplerU_in, prevUV, 0), f.xz, Damping);
}
// Advect step

View file

@ -16,6 +16,7 @@ namespace StableFluids
[SerializeField] int _resolution = 512;
[SerializeField] float _viscosity = 1e-6f;
[SerializeField] float _damping = .05f;
[SerializeField] float _range = 512;
[SerializeField] Transform _camera;
@ -49,6 +50,7 @@ namespace StableFluids
public const int PFinish = 3;
public const int Jacobi1 = 4;
public const int Jacobi2 = 5;
public const int Adjust = 6;
}
int ThreadCount { get { return (_resolution + 7) / 8; } }
@ -132,13 +134,18 @@ namespace StableFluids
Shader.SetGlobalVector("_FluidTransform", new Vector4(cameraPosition.x, cameraPosition.y, _range));
var delta = (float2)(cameraIntPosition - _previousCameraIntPosition) / Resolution;
_compute.SetVector("Delta", new Vector4(delta.x,delta.y));
_compute.SetFloat("Damping", _damping);
_compute.SetTexture(Kernels.Adjust, "U_in", VFB.V1);
_compute.SetTexture(Kernels.Adjust, "W_out", VFB.V3);
_compute.Dispatch(Kernels.Adjust, ThreadCount, ThreadCount, 1);
// Common variables
_compute.SetFloat("Time", Time.time);
_compute.SetFloat("DeltaTime", dt);
// Advection
_compute.SetTexture(Kernels.Advect, "U_in", VFB.V1);
_compute.SetTexture(Kernels.Advect, "U_in", VFB.V3);
_compute.SetTexture(Kernels.Advect, "W_out", VFB.V2);
_compute.Dispatch(Kernels.Advect, ThreadCount, ThreadCount, 1);

View file

@ -145,10 +145,10 @@ float density(float3 pos)
const float noise1 = pow(triNoise3d((pos+fl * lerp1 * _FlowPeriod) / _NebulaNoiseScale),_NebulaNoiseExponent) * _NebulaNoiseAmplitude * tri2(lerp1);
const float noise2 = pow(triNoise3d((pos+fl * lerp2 * _FlowPeriod) / _NebulaNoiseScale),_NebulaNoiseExponent) * _NebulaNoiseAmplitude * tri2(lerp2);
pos.y += (noise1 + noise2) * heightFade;
const float lerp3 = frac(_Time.y / _FlowPeriod);
const float lerp4 = frac(_Time.y / _FlowPeriod + .5);
const float noise3 = pow(triNoise3d((pos+fl * lerp3 * _FlowPeriod) / _NebulaNoiseScale * 8), _NebulaNoiseExponent) * _NebulaNoiseAmplitude * tri2(lerp3) / 2;
const float noise4 = pow(triNoise3d((pos+fl * lerp4 * _FlowPeriod) / _NebulaNoiseScale * 8), _NebulaNoiseExponent) * _NebulaNoiseAmplitude * tri2(lerp4) / 2;
const float lerp3 = frac(_Time.y / _FlowPeriod * 2);
const float lerp4 = frac(_Time.y / _FlowPeriod * 2 + .5);
const float noise3 = pow(triNoise3d((pos+fl * lerp3 * _FlowPeriod / 2) / _NebulaNoiseScale * 8), _NebulaNoiseExponent) * _NebulaNoiseAmplitude * tri2(lerp3) / 2;
const float noise4 = pow(triNoise3d((pos+fl * lerp4 * _FlowPeriod / 2) / _NebulaNoiseScale * 8), _NebulaNoiseExponent) * _NebulaNoiseAmplitude * tri2(lerp4) / 2;
pos.y -= (noise3 + noise4) * heightFade;
d += cloudDensity(pos, surfaceDisp);
}
@ -179,5 +179,5 @@ float3 VolumeSampleColorSimple(float3 pos, float3 normal)
float3 high = tex2Dlod(_NebulaTint, float4(uv.x, uv.y, 0, _DynamicLodBias + _DynamicLodRange)).rgb * _DynamicSkyBoost;
float upness = dot(normal, float3(0,1,0));
//float lambert = 2 - dot(normalize(normal.xz), normalize(tintGradient(uv)));
return lerp(low,high,(upness+1)/2) * _DynamicIntensity / (density(pos)+1);
return lerp(low,high,sqrt((upness+1)/2)) * _DynamicIntensity / (density(pos)+1);
}

BIN
GameData/PlayerSettings.msgpack (Stored with Git LFS)

Binary file not shown.

BIN
UserSettings/EditorUserSettings.asset (Stored with Git LFS)

Binary file not shown.