From 7210d298af2f531920cf664a17688c0e0af0dfed Mon Sep 17 00:00:00 2001 From: Reinier Vens Date: Tue, 12 Jul 2022 14:22:23 +0100 Subject: [PATCH] More Nebula Fuckery Performance optimization for nebula raymarching Fixed zone generator crashing due to lack of station and turret hull data (where'd they go?!) --- Assets/Materials/Brushes/Fog Tint.mat | 2 +- .../Brushes/Main Menu Sun Fog Tint.mat | 4 +- .../Brushes/Sector Patch Displacement.mat | 2 +- Assets/Materials/Brushes/Wormhole Gravity.mat | 2 +- .../Materials/Brushes/Wormhole Lighting.mat | 4 +- .../Shaders/CloudNormalRaymarch.cginc | 2 +- .../Shaders/CloudShaderHelper.cginc | 6 +- Assets/Resources/Fog Tint.renderTexture | 2 +- Assets/Resources/Settings.asset | 4 +- Assets/Scenes/ARPG.unity | 8 +- .../Postprocessing Profile Main Menu.asset | 2 +- Assets/Scenes/Main Menu.unity | 20 ++-- .../Scripts/ServerShared/LoadoutGenerator.cs | 18 ++- Assets/Scripts/ServerShared/ZoneGenerator.cs | 6 +- .../Shaders/Compute/Stardust/Stardust.compute | 6 +- Assets/Shaders/Volumetric.cginc | 106 ++++++------------ GameData/PlayerSettings.msgpack | 4 +- 17 files changed, 90 insertions(+), 108 deletions(-) diff --git a/Assets/Materials/Brushes/Fog Tint.mat b/Assets/Materials/Brushes/Fog Tint.mat index 53b4e03f0..e8fb9d952 100644 --- a/Assets/Materials/Brushes/Fog Tint.mat +++ b/Assets/Materials/Brushes/Fog Tint.mat @@ -58,7 +58,7 @@ Material: m_Floats: - _BumpScale: 1 - _Cutoff: 1 - - _Depth: 0.5 + - _Depth: 0.25 - _DetailNormalMapScale: 1 - _DstBlend: 0 - _Frequency: 6.2832 diff --git a/Assets/Materials/Brushes/Main Menu Sun Fog Tint.mat b/Assets/Materials/Brushes/Main Menu Sun Fog Tint.mat index 4833fd074..dcd8533d8 100644 --- a/Assets/Materials/Brushes/Main Menu Sun Fog Tint.mat +++ b/Assets/Materials/Brushes/Main Menu Sun Fog Tint.mat @@ -58,7 +58,7 @@ Material: m_Floats: - _BumpScale: 1 - _Cutoff: 1 - - _Depth: 2 + - _Depth: 15 - _DetailNormalMapScale: 1 - _DstBlend: 0 - _Frequency: 6.2832 @@ -70,7 +70,7 @@ Material: - _OcclusionStrength: 1 - _Parallax: 0.02 - _Phase: 0 - - _Power: 2 + - _Power: 3 - _SinePower: 1.25 - _SmoothnessTextureChannel: 0 - _SpecularHighlights: 1 diff --git a/Assets/Materials/Brushes/Sector Patch Displacement.mat b/Assets/Materials/Brushes/Sector Patch Displacement.mat index 7ef73d9fc..09aeda5ab 100644 --- a/Assets/Materials/Brushes/Sector Patch Displacement.mat +++ b/Assets/Materials/Brushes/Sector Patch Displacement.mat @@ -57,7 +57,7 @@ Material: m_Offset: {x: 0, y: 0} m_Floats: - _BumpScale: 1 - - _Constant: -51.6 + - _Constant: -30 - _Cutoff: 0.5 - _Depth: 10 - _DetailNormalMapScale: 1 diff --git a/Assets/Materials/Brushes/Wormhole Gravity.mat b/Assets/Materials/Brushes/Wormhole Gravity.mat index afce9c26c..cab097589 100644 --- a/Assets/Materials/Brushes/Wormhole Gravity.mat +++ b/Assets/Materials/Brushes/Wormhole Gravity.mat @@ -57,7 +57,7 @@ Material: m_Offset: {x: 0, y: 0} m_Floats: - _BumpScale: 1 - - _Cutoff: 0.153 + - _Cutoff: 0.1 - _Depth: 2000 - _DetailNormalMapScale: 1 - _DstBlend: 0 diff --git a/Assets/Materials/Brushes/Wormhole Lighting.mat b/Assets/Materials/Brushes/Wormhole Lighting.mat index 2072b00bb..a12af25d6 100644 --- a/Assets/Materials/Brushes/Wormhole Lighting.mat +++ b/Assets/Materials/Brushes/Wormhole Lighting.mat @@ -58,7 +58,7 @@ Material: m_Floats: - _BumpScale: 1 - _Cutoff: 1 - - _Depth: 8 + - _Depth: 15 - _DetailNormalMapScale: 1 - _DstBlend: 0 - _Frequency: 6.2832 @@ -70,7 +70,7 @@ Material: - _OcclusionStrength: 1 - _Parallax: 0.02 - _Phase: 0 - - _Power: 124.97 + - _Power: 128 - _SinePower: 1.25 - _SmoothnessTextureChannel: 0 - _SpecularHighlights: 1 diff --git a/Assets/Plugins/VolumeCloud/Shaders/CloudNormalRaymarch.cginc b/Assets/Plugins/VolumeCloud/Shaders/CloudNormalRaymarch.cginc index 3bfe565e2..010d7c1c4 100644 --- a/Assets/Plugins/VolumeCloud/Shaders/CloudNormalRaymarch.cginc +++ b/Assets/Plugins/VolumeCloud/Shaders/CloudNormalRaymarch.cginc @@ -14,7 +14,7 @@ float GetDensity(float3 startPos, float3 dir, float maxSampleDistance, float ray if(raymarchDistance > maxSampleDistance) break; float step = raymarchDistance - prevRayDist; float3 rayPos = startPos + dir * raymarchDistance; - float fade = smoothstep(_ProjectionParams.z*.75,_ProjectionParams.z*.95, raymarchDistance); + float fade = smoothstep(_ProjectionParams.z*.95,_ProjectionParams.z, raymarchDistance); IntegrateRaymarch(startPos, rayPos, fade, step, result); if (result.intTransmittance < 0.01f) { result.intTransmittance = 0; diff --git a/Assets/Plugins/VolumeCloud/Shaders/CloudShaderHelper.cginc b/Assets/Plugins/VolumeCloud/Shaders/CloudShaderHelper.cginc index 3e0a3527d..951242783 100644 --- a/Assets/Plugins/VolumeCloud/Shaders/CloudShaderHelper.cginc +++ b/Assets/Plugins/VolumeCloud/Shaders/CloudShaderHelper.cginc @@ -117,7 +117,7 @@ float ApplyCoverageToDensity(float sampleResult, float coverage){ float SampleDensity(float3 worldPos,int lod, bool cheap, out float wetness) { wetness = 0; - return d(worldPos)*_CloudOverallDensity*10; + return density(worldPos)*_CloudOverallDensity*10; // //Store the pos without wind applied. // float3 unwindWorldPos = worldPos; // @@ -292,7 +292,7 @@ void InitRaymarchStatus(inout RaymarchStatus result){ void IntegrateRaymarch(float3 startPos, float3 rayPos, float fade, float stepsize, inout RaymarchStatus result){ float4 c = VolumeSampleColor(rayPos); - float density = c.a;//SampleDensity(rayPos, 0, false, wetness); + float density = c.a; if (density <= 0.0f) return; float extinction = _ExtinctionCoefficient * density; @@ -300,7 +300,7 @@ void IntegrateRaymarch(float3 startPos, float3 rayPos, float fade, float stepsiz float clampedExtinction = max(extinction, 1e-7); float transmittance = exp(-extinction * stepsize); - float3 luminance = c.rgb * (1-fade);//SampleEnergy(rayPos, viewdir); + float3 luminance = c.rgb * (1-fade); float3 integScatt = (luminance - luminance * transmittance) / clampedExtinction; float depthWeight = result.intTransmittance * (1-transmittance); //Is it a better idead to use (1-transmittance) * intTransmittance as depth weight? diff --git a/Assets/Resources/Fog Tint.renderTexture b/Assets/Resources/Fog Tint.renderTexture index 0aedaec60..ce5104847 100644 --- a/Assets/Resources/Fog Tint.renderTexture +++ b/Assets/Resources/Fog Tint.renderTexture @@ -28,7 +28,7 @@ RenderTexture: m_EnableCompatibleFormat: 1 m_TextureSettings: serializedVersion: 2 - m_FilterMode: 1 + m_FilterMode: 2 m_Aniso: 0 m_MipBias: 0 m_WrapU: 1 diff --git a/Assets/Resources/Settings.asset b/Assets/Resources/Settings.asset index f53a4fdd6..844987a31 100644 --- a/Assets/Resources/Settings.asset +++ b/Assets/Resources/Settings.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9ebacec60cdc507554e2947f150d69fccaa745892836858dbedd2fb2df6747f9 -size 13037 +oid sha256:6bc6efe53038a29fd90adddc230e251bef3e17bf10d1996ec5c041a641cbda48 +size 13041 diff --git a/Assets/Scenes/ARPG.unity b/Assets/Scenes/ARPG.unity index 902a640e2..5f307d3dd 100644 --- a/Assets/Scenes/ARPG.unity +++ b/Assets/Scenes/ARPG.unity @@ -16184,11 +16184,11 @@ MonoBehaviour: Span: 128 Speed: -0.15 MinimumSize: 0 - MaximumSize: 0.5 + MaximumSize: 0.75 Spacing: 6 - Ceiling: -200 - Floor: -40 - HeightExponent: 1000000 + Ceiling: -300 + Floor: -20 + HeightExponent: 100000 NebulaSurfaceHeight: {fileID: 8400000, guid: 2fc21a9d3e9647948b56e384cd9378b3, type: 2} NebulaPatchHeight: {fileID: 8400000, guid: c618a6b20b3c7394590c59a9fa467e86, type: 2} NebulaPatch: {fileID: 8400000, guid: 06ec5ef8a5830fc44b1ac1a6e123add5, type: 2} diff --git a/Assets/Scenes/ARPG_Profiles/Postprocessing Profile Main Menu.asset b/Assets/Scenes/ARPG_Profiles/Postprocessing Profile Main Menu.asset index b6582f31b..906e57666 100644 --- a/Assets/Scenes/ARPG_Profiles/Postprocessing Profile Main Menu.asset +++ b/Assets/Scenes/ARPG_Profiles/Postprocessing Profile Main Menu.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:eb91bceb1b8e4c3cf6a32569fa14b6f2956cbcd8ac493c0336f8f19c00eb638e +oid sha256:fa0c97918c5f9d4d7e9e501ed919fe1448d5e316294b2d79447abaaffbc6c2c5 size 27013 diff --git a/Assets/Scenes/Main Menu.unity b/Assets/Scenes/Main Menu.unity index db306e2d5..0b7794236 100644 --- a/Assets/Scenes/Main Menu.unity +++ b/Assets/Scenes/Main Menu.unity @@ -400,7 +400,7 @@ MonoBehaviour: m_HorizontalDamping: 0.5 m_VerticalDamping: 0.5 m_ScreenX: 0.45 - m_ScreenY: 0.45 + m_ScreenY: 0.39 m_DeadZoneWidth: 0 m_DeadZoneHeight: 0 m_SoftZoneWidth: 0.8 @@ -440,8 +440,8 @@ MonoBehaviour: m_YDamping: 0 m_ZDamping: 0 m_TargetMovementOnly: 0 - m_ScreenX: 0.75 - m_ScreenY: 0.75 + m_ScreenX: 0.74 + m_ScreenY: 0.6 m_CameraDistance: 381.18 m_DeadZoneWidth: 0 m_DeadZoneHeight: 0 @@ -802,8 +802,8 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 741153267} - m_LocalRotation: {x: 0.24134962, y: 0.7351235, z: -0.5426147, w: 0.32697564} - m_LocalPosition: {x: -144.21849, y: 325.46454, z: 116.09439} + m_LocalRotation: {x: 0.17419034, y: 0.82403576, z: -0.4098015, w: 0.3502649} + m_LocalPosition: {x: -255.6498, y: 261.96085, z: 220.16467} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 412917866} @@ -865,8 +865,8 @@ MonoBehaviour: MaximumSize: 0.5 Spacing: 6 Ceiling: 200 - Floor: -50 - HeightExponent: 1000000 + Floor: -10 + HeightExponent: 300000 NebulaSurfaceHeight: {fileID: 8400000, guid: 2fc21a9d3e9647948b56e384cd9378b3, type: 2} NebulaPatchHeight: {fileID: 8400000, guid: c618a6b20b3c7394590c59a9fa467e86, type: 2} NebulaPatch: {fileID: 8400000, guid: 06ec5ef8a5830fc44b1ac1a6e123add5, type: 2} @@ -1252,8 +1252,8 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 965376321} - m_LocalRotation: {x: 0.24134962, y: 0.7351235, z: -0.5426147, w: 0.32697564} - m_LocalPosition: {x: -144.21849, y: 325.46454, z: 116.09439} + m_LocalRotation: {x: 0.17419034, y: 0.82403576, z: -0.4098015, w: 0.3502649} + m_LocalPosition: {x: -255.6498, y: 261.96085, z: 220.16467} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} @@ -1671,7 +1671,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1362573162} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: -214, z: 0} + m_LocalPosition: {x: 0, y: -125, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} diff --git a/Assets/Scripts/ServerShared/LoadoutGenerator.cs b/Assets/Scripts/ServerShared/LoadoutGenerator.cs index 56904c902..1fba90964 100644 --- a/Assets/Scripts/ServerShared/LoadoutGenerator.cs +++ b/Assets/Scripts/ServerShared/LoadoutGenerator.cs @@ -46,6 +46,11 @@ public class LoadoutGenerator public EntityPack GenerateShipLoadout(Predicate hullFilter = null) { var hullData = RandomHull(HullType.Ship, hullFilter); + if(hullData==null) + { + ItemManager.Log("Unable to generate ship loadout: no compatible hull found!"); + return null; + } var hull = ItemManager.CreateInstance(hullData) as EquippableItem; if(hull==null) ItemManager.Log("WHAT???"); @@ -57,7 +62,13 @@ public class LoadoutGenerator public OrbitalEntityPack GenerateTurretLoadout() { - var hull = ItemManager.CreateInstance(RandomHull(HullType.Turret)) as EquippableItem; + var hullData = RandomHull(HullType.Turret); + if(hullData==null) + { + ItemManager.Log("Unable to generate turret loadout: no compatible hull found!"); + return null; + } + var hull = ItemManager.CreateInstance(hullData) as EquippableItem; var entity = new OrbitalEntity(ItemManager, null, hull, Guid.Empty, ItemManager.GameplaySettings.DefaultEntitySettings); entity.Faction = Faction; OutfitEntity(entity); @@ -67,6 +78,11 @@ public class LoadoutGenerator public OrbitalEntityPack GenerateStationLoadout() { var hullData = RandomHull(HullType.Station); + if(hullData==null) + { + ItemManager.Log("Unable to generate station loadout: no compatible hull found!"); + return null; + } var hull = ItemManager.CreateInstance(hullData) as EquippableItem; var entity = new OrbitalEntity(ItemManager, null, hull, Guid.Empty, ItemManager.GameplaySettings.DefaultEntitySettings); entity.Faction = Faction; diff --git a/Assets/Scripts/ServerShared/ZoneGenerator.cs b/Assets/Scripts/ServerShared/ZoneGenerator.cs index ea09f36dc..0bf33077f 100644 --- a/Assets/Scripts/ServerShared/ZoneGenerator.cs +++ b/Assets/Scripts/ServerShared/ZoneGenerator.cs @@ -277,6 +277,7 @@ public static class ZoneGenerator }; pack.Orbits.Add(turretOrbit); var turret = loadoutGenerator.GenerateTurretLoadout(); + if (turret == null) return; turret.Orbit = turretOrbit.ID; pack.Entities.Add(turret); } @@ -313,6 +314,7 @@ public static class ZoneGenerator var lagrangeOrbit = CreateLagrangeOrbit(orbit); var station = GetLoadoutGenerator(nearestFaction).GenerateStationLoadout(); + if (station == null) continue; station.Orbit = lagrangeOrbit.ID; station.SecurityLevel = security; station.SecurityRadius = pack.Radius; @@ -324,7 +326,9 @@ public static class ZoneGenerator var enemyCount = (int)(random.NextFloat() * factionPresence * 2) + stationCount; for (int i = 0; i < enemyCount; i++) { - pack.Entities.Add(GetLoadoutGenerator(nearestFaction).GenerateShipLoadout()); + var ship = GetLoadoutGenerator(nearestFaction).GenerateShipLoadout(); + if (ship == null) continue; + pack.Entities.Add(ship); } return pack; diff --git a/Assets/Shaders/Compute/Stardust/Stardust.compute b/Assets/Shaders/Compute/Stardust/Stardust.compute index ce0159192..08a1404aa 100644 --- a/Assets/Shaders/Compute/Stardust/Stardust.compute +++ b/Assets/Shaders/Compute/Stardust/Stardust.compute @@ -135,7 +135,7 @@ void UpdateParticles(uint3 id : SV_DispatchThreadID, int3 groupID : SV_GroupThre float noise; const float3 flowDir = flow(particles[id.x].position, noise); particles[id.x].position += flowDir * (lifetime * noise); - const float density = pow(f(particles[id.x].position) + .01, 0.15); - particles[id.x].size = lerp(minimumSize, maximumSize, saturate(RandomValue() * density)) * parabola(lifetime, 2); - particles[id.x].color = HueTexture.SampleLevel(samplerHueTexture, float2(RandomValue(), 0.0f), 0.0f).rgb * density; + const float d = pow(density(particles[id.x].position) + .01, 0.15); + particles[id.x].size = lerp(minimumSize, maximumSize, saturate(RandomValue() * d)) * parabola(lifetime, 2); + particles[id.x].color = HueTexture.SampleLevel(samplerHueTexture, float2(RandomValue(), 0.0f), 0.0f).rgb * d; } \ No newline at end of file diff --git a/Assets/Shaders/Volumetric.cginc b/Assets/Shaders/Volumetric.cginc index 095e30298..0439d1fe1 100644 --- a/Assets/Shaders/Volumetric.cginc +++ b/Assets/Shaders/Volumetric.cginc @@ -97,63 +97,17 @@ float2 getUV(float3 pos) return -(pos.xz-_GridTransform.xy)/_GridTransform.z + float2(.5,.5); } -float f(float3 pos) +float cloudDensity(float3 pos, float surfaceDisp) { float2 uv = getUV(pos); - const float surfaceDisp = tex2Dlod(_NebulaSurfaceHeight, half4(uv, 0, 0)).r; const float dist = pos.y + surfaceDisp - _NebulaFloorOffset; + const float patch = tex2Dlod(_NebulaPatch, half4(uv, 0, 0)).r; + const float patchDisp = tex2Dlod(_NebulaPatchHeight, half4(uv, 0, 0)).r; - const float fillDensity = smoothstep(min(_SafetyDistance,surfaceDisp),0,dist) * _NebulaFillDensity; - - if(dist < _SafetyDistance) - { - const float patch = tex2Dlod(_NebulaPatch, half4(uv, 0, 0)).r; - const float patchDisp = tex2Dlod(_NebulaPatchHeight, half4(uv, 0, 0)).r; - - const float patchDensity = saturate((-abs(pos.y+patchDisp - _NebulaFloorOffset)+patch)/_NebulaPatchBlend)*_NebulaPatchDensity; - const float floorDist = -dist; - const float floorDensity = floorDist/_NebulaFloorBlend*_NebulaFloorDensity; - const float fogDensity = patchDensity + max(0,floorDensity); - return fogDensity + fillDensity; - } - - return fillDensity; - -} - -float3 calcNormal (float3 pos, float2 uv) -{ - float3 n = float3(pos.x, - tex2D(_NebulaSurfaceHeight, float2(uv.x, uv.y + _NebulaSurfaceHeight_TexelSize.y)).x, - pos.z + _NebulaSurfaceHeight_TexelSize.y * _GridTransform.z); - float3 me = float3(pos.x, - tex2D(_NebulaSurfaceHeight, float2(uv.x, uv.y)).x, - pos.z); - float3 e = float3(pos.x + _NebulaSurfaceHeight_TexelSize.x * _GridTransform.z, - tex2D(_NebulaSurfaceHeight, float2(uv.x + _NebulaSurfaceHeight_TexelSize.x, uv.y)).x, - pos.z); - float3 norm = cross(normalize(n-me),normalize(e-me)); - return norm; -} - -float2 tintGradient (float3 pos, float2 uv, float mip, out float3 tint) -{ - tint = tex2Dlod(_NebulaTint, float4(uv.x, uv.y, 0, mip)); - float me = length(tint); - return float2( - length(tex2Dlod(_NebulaTint, float4(uv.x + 0.001953125, uv.y, 0, mip))) - me, - length(tex2Dlod(_NebulaTint, float4(uv.x, uv.y + 0.001953125, 0, mip))) - me - ); -} - -float3 calcNormal( float3 p ) // for function f(p) -{ - const float h = 0.0001; // replace by an appropriate value - const float2 k = float2(1,-1); - return normalize( k.xyy*f( p + k.xyy*h ) + - k.yyx*f( p + k.yyx*h ) + - k.yxy*f( p + k.yxy*h ) + - k.xxx*f( p + k.xxx*h ) ); + const float patchDensity = saturate((-abs(pos.y+patchDisp - _NebulaFloorOffset)+patch)/_NebulaPatchBlend)*_NebulaPatchDensity; + const float floorDist = -dist; + const float floorDensity = floorDist/_NebulaFloorBlend*_NebulaFloorDensity; + return patchDensity + max(0,floorDensity); } float3 flow(float3 pos, out float noise) @@ -166,33 +120,41 @@ float3 flow(float3 pos, out float noise) float tri2(in float x){return 1-2*abs(frac(x)-.5);} -float d(float3 pos) +float density(float3 pos) { - float noise; - const float3 fl = flow(pos, noise); - const float lerp1 = frac(_Time.x * _FlowSpeed + noise); - const float lerp2 = frac(_Time.x * _FlowSpeed + .5 + noise); - const float noise1 = pow(triNoise3d((pos+fl * lerp1) / _NoiseScale),_NoiseExponent) * _NoiseAmplitude * tri2(lerp1); - const float noise2 = pow(triNoise3d((pos+fl * lerp2) / _NoiseScale),_NoiseExponent) * _NoiseAmplitude * tri2(lerp2); - pos.y += (noise1 + noise2); - const float lerp3 = frac(_Time.x * _FlowSpeed * 2); - const float lerp4 = frac(_Time.x * _FlowSpeed * 2 + .5); - const float noise3 = pow(triNoise3d((pos+fl * lerp3) / _NoiseScale * 2), _NoiseExponent) * _NoiseAmplitude * tri2(lerp3) / 2; - const float noise4 = pow(triNoise3d((pos+fl * lerp4) / _NoiseScale * 2), _NoiseExponent) * _NoiseAmplitude * tri2(lerp4) / 2; - pos.y -= (noise3 + noise4); - return f(pos); + float2 uv = getUV(pos); + const float surfaceDisp = tex2Dlod(_NebulaSurfaceHeight, half4(uv, 0, 0)).r; + const float dist = pos.y + surfaceDisp; + float d = pow((dist+20)/300,-2) * _NebulaFillDensity; + if(dist < _SafetyDistance) + { + const float heightFade = smoothstep(_SafetyDistance,_SafetyDistance*.75,dist); + float noise; + const float3 fl = flow(pos, noise); + const float lerp1 = frac(_Time.x * _FlowSpeed + noise); + const float lerp2 = frac(_Time.x * _FlowSpeed + .5 + noise); + const float noise1 = pow(triNoise3d((pos+fl * lerp1) / _NoiseScale),_NoiseExponent) * _NoiseAmplitude * tri2(lerp1); + const float noise2 = pow(triNoise3d((pos+fl * lerp2) / _NoiseScale),_NoiseExponent) * _NoiseAmplitude * tri2(lerp2); + pos.y += (noise1 + noise2) * heightFade; + const float lerp3 = frac(_Time.x * _FlowSpeed * 2); + const float lerp4 = frac(_Time.x * _FlowSpeed * 2 + .5); + const float noise3 = pow(triNoise3d((pos+fl * lerp3) / _NoiseScale * 4), _NoiseExponent) * _NoiseAmplitude * tri2(lerp3) / 2; + const float noise4 = pow(triNoise3d((pos+fl * lerp4) / _NoiseScale * 4), _NoiseExponent) * _NoiseAmplitude * tri2(lerp4) / 2; + pos.y -= (noise3 + noise4) * heightFade; + d += cloudDensity(pos, surfaceDisp); + } + return d; } float4 VolumeSampleColor(float3 pos) { - float density = d(pos); - float clampedDensity = max(.01,density); + float d = density(pos); float2 uv = getUV(pos); - float3 tint = tex2Dlod(_NebulaTint, float4(uv.x, uv.y, 0, pow(clampedDensity, _TintLodExponent))); + float3 tint = tex2Dlod(_NebulaTint, float4(uv.x, uv.y, 0, pow(max(.01,d), _TintLodExponent))); //float2 tintGrad = tintGradient(pos, uv, 1 / pow(density, .25), tint); //float3 tintNormal = normalize(float3(tintGrad.x, 0, tintGrad.y)); //tint *= abs(dot(normal, float3(0,-1,0))); // pow(abs(1-density), _TintExponent) - const float albedo = smoothstep(0,-250,pos.y) * pow(clampedDensity, _TintExponent) * _NebulaLuminance; - return float4(albedo*tint, density); + const float albedo = smoothstep(0,-250,pos.y) * pow(max(.1,d), _TintExponent) * _NebulaLuminance; + return float4(albedo*tint, d); } diff --git a/GameData/PlayerSettings.msgpack b/GameData/PlayerSettings.msgpack index d36992078..ed16776fd 100644 --- a/GameData/PlayerSettings.msgpack +++ b/GameData/PlayerSettings.msgpack @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:26f3052712711b163af0a4324cb906cfa10af9b9dfadd5870aa22c5fee6804a3 -size 20009 +oid sha256:3b1ac15ed3a5fe86725731b46db845d98628b9778006a988f0837ba7c16f662f +size 54051