Skip to content

Commit

Permalink
🐛 Fix #1145 UR Density Factor not supporting Portals
Browse files Browse the repository at this point in the history
  • Loading branch information
daleeidd committed Apr 6, 2024
1 parent d137997 commit 86f9e03
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion crest/Assets/Crest/Crest/Shaders/Helpers/WaterVolume.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ TEXTURE2D_X(_CrestWaterVolumeFrontFaceTexture);
TEXTURE2D_X(_CrestWaterVolumeBackFaceTexture);

#if CREST_WATER_VOLUME
void ApplyVolumeToOceanSurface(const float4 i_positionCS)
float ApplyVolumeToOceanSurface(const float4 i_positionCS)
{
#if CREST_WATER_VOLUME_HAS_BACKFACE
// Discard ocean after volume or when not on pixel.
Expand All @@ -34,6 +34,8 @@ void ApplyVolumeToOceanSurface(const float4 i_positionCS)
discard;
}
#endif // CREST_WATER_VOLUME_2D

return rawFrontFaceZ;
}
#endif

Expand Down
8 changes: 6 additions & 2 deletions crest/Assets/Crest/Crest/Shaders/Ocean.shader
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ Shader "Crest/Ocean"
half2 uvDepth = screenPos.xy / screenPos.z;

#if CREST_WATER_VOLUME
ApplyVolumeToOceanSurface(input.positionCS);
float rawFrontFaceZ = ApplyVolumeToOceanSurface(input.positionCS);
#endif

#if _CLIPUNDERTERRAIN_ON
Expand Down Expand Up @@ -739,8 +739,12 @@ Shader "Crest/Ocean"
#if CREST_UNDERWATER_BEFORE_TRANSPARENT
else
{
float depthFogDistance = pixelZ;
#if CREST_WATER_VOLUME
depthFogDistance -= CrestLinearEyeDepth(rawFrontFaceZ);
#endif
// underwater - do depth fog
col = lerp(col, scatterCol, saturate(1. - exp(-_CrestDepthFogDensity.xyz * pixelZ)));
col = lerp(col, scatterCol, saturate(1. - exp(-_CrestDepthFogDensity.xyz * depthFogDistance)));
}
#endif

Expand Down

0 comments on commit 86f9e03

Please sign in to comment.