Skip to content

Commit 22945ea

Browse files
committed
- Fixed the fade in mode of the clouds not impacting the volumetric clouds shadows (case 1381652).
1 parent cd397ac commit 22945ea

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

com.unity.render-pipelines.high-definition/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
5959
- Fixed HDRP build issues with DOTS_INSTANCING_ON shader variant.
6060
- Fixed default value of "Distortion Blur" from 1 to 0 according to the doc.
6161
- Fixed Transparent Depth Pre/Post pass by default for the built-in HDRP Hair shader graph.
62+
- Fixed the fade in mode of the clouds not impacting the volumetric clouds shadows (case 1381652).
6263

6364
## [13.1.2] - 2021-11-05
6465

com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/HDRenderPipeline.VolumetricClouds.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ void UpdateShaderVariableslClouds(ref ShaderVariablesClouds cb, HDCamera hdCamer
490490
float groundShadowSize = settings.shadowDistance.value;
491491

492492
// The world space camera will be required but the global constant buffer will not be injected yet.
493-
cb._WorldSpaceShadowCenter = new Vector2(hdCamera.camera.transform.position.x, hdCamera.camera.transform.position.z);
493+
cb._WorldSpaceShadowCenter = new Vector4(hdCamera.camera.transform.position.x, hdCamera.camera.transform.position.y, hdCamera.camera.transform.position.z, 0.0f);
494494

495495
if (HasVolumetricCloudsShadows(hdCamera, settings))
496496
{

com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricClouds.compute

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,7 @@ void ComputeVolumetricCloudsShadow(uint3 currentCoords : SV_DispatchThreadID, ui
15731573

15741574
// Compute the position of the shadow plane
15751575
#ifdef LOCAL_VOLUMETRIC_CLOUDS
1576-
float3 shadowCookieCenterWS = float3(_WorldSpaceShadowCenter.x, _ShadowPlaneOffset, _WorldSpaceShadowCenter.y) + t * _SunDirection.xyz;
1576+
float3 shadowCookieCenterWS = float3(_WorldSpaceShadowCenter.x, _ShadowPlaneOffset, _WorldSpaceShadowCenter.z) + t * _SunDirection.xyz;
15771577
#else
15781578
float3 shadowCookieCenterWS = t * _SunDirection.xyz;
15791579
#endif
@@ -1612,6 +1612,10 @@ void ComputeVolumetricCloudsShadow(uint3 currentCoords : SV_DispatchThreadID, ui
16121612
// Compute the cloud density
16131613
CloudProperties cloudProperties;
16141614
EvaluateCloudProperties(positionWS, 0.0, 0.0, true, true, cloudProperties);
1615+
1616+
// Apply the camera fade it to match the clouds perceived by the camera
1617+
cloudProperties.density = DensityFadeIn(cloudProperties.density, length(positionWS - _WorldSpaceShadowCenter.xyz));
1618+
16151619
if (cloudProperties.density > CLOUD_DENSITY_TRESHOLD)
16161620
{
16171621
// Apply the extinction

com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricCloudsDef.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,10 @@ unsafe struct ShaderVariablesClouds
130130

131131
// The size of the shadow region (meters)
132132
public Vector2 _ShadowRegionSize;
133+
public Vector2 _PaddingVC0;
133134

134-
// World Camera Position used as the constant buffer has not been injected yet when this data is required
135-
public Vector2 _WorldSpaceShadowCenter;
135+
// World Camera Position used as the constant buffer has not been injected yet when this data is required, last channel is unused.
136+
public Vector4 _WorldSpaceShadowCenter;
136137

137138
// View projection matrix (non oblique) for the planar reflection matrices
138139
public Matrix4x4 _CameraViewProjection_NO;

com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricCloudsDef.cs.hlsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ CBUFFER_START(ShaderVariablesClouds)
6161
int _ShadowCookieResolution;
6262
float _ShadowPlaneOffset;
6363
float2 _ShadowRegionSize;
64-
float2 _WorldSpaceShadowCenter;
64+
float2 _PaddingVC0;
65+
float4 _WorldSpaceShadowCenter;
6566
float4x4 _CameraViewProjection_NO;
6667
float4x4 _CameraInverseViewProjection_NO;
6768
float4x4 _CameraPrevViewProjection_NO;

0 commit comments

Comments
 (0)