Skip to content

Commit a43d0ac

Browse files
anisunitysebastienlagarde
authored andcommitted
Fixed the fade in mode of the clouds not impacting the volumetric clouds shadows (case 1381652). #6511
1 parent 584aef3 commit a43d0ac

File tree

9 files changed

+20
-13
lines changed

9 files changed

+20
-13
lines changed
Loading
Loading
Loading
Loading

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1010
- Fixed Correlated Color Temperature not being applied in Player builds for Enlighten realtime GI lights (case 1370438);
1111
- Fixed Normal Map assiignation when importing FBX Materials.
1212
- Fixed rendering in the editor when an incompatible API is added (case 1384634).
13+
- Fixed the fade in mode of the clouds not impacting the volumetric clouds shadows (case 1381652).
1314

1415
## [13.1.4] - 2021-12-04
1516

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
@@ -492,7 +492,7 @@ void UpdateShaderVariableslClouds(ref ShaderVariablesClouds cb, HDCamera hdCamer
492492
float groundShadowSize = settings.shadowDistance.value;
493493

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

497497
if (HasVolumetricCloudsShadows(hdCamera, settings))
498498
{

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)