From 83c874c10aba35cf37d292f281530aba77c717c8 Mon Sep 17 00:00:00 2001 From: anisunity Date: Tue, 7 Dec 2021 13:53:16 +0100 Subject: [PATCH 1/3] - Fixed the fade in mode of the clouds not impacting the volumetric clouds shadows (case 1381652). --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + .../VolumetricLighting/HDRenderPipeline.VolumetricClouds.cs | 2 +- .../Lighting/VolumetricLighting/VolumetricClouds.compute | 6 +++++- .../Lighting/VolumetricLighting/VolumetricCloudsDef.cs | 5 +++-- .../Lighting/VolumetricLighting/VolumetricCloudsDef.cs.hlsl | 3 ++- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 77c3e66f9a9..4ab96c2d175 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -72,6 +72,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed compilation issue related to shader stripping in ray tracing. - Fixed flipped UV for directional light cookie on PBR Sky (case 1382656). - Fixing missing doc API for RTAS Debug display. +- Fixed the fade in mode of the clouds not impacting the volumetric clouds shadows (case 1381652). ### Changed - Converted most TGA textures files to TIF to reduce the size of HDRP material samples. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/HDRenderPipeline.VolumetricClouds.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/HDRenderPipeline.VolumetricClouds.cs index 7ca4f2496eb..857ede79cd7 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/HDRenderPipeline.VolumetricClouds.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/HDRenderPipeline.VolumetricClouds.cs @@ -488,7 +488,7 @@ void UpdateShaderVariableslClouds(ref ShaderVariablesClouds cb, HDCamera hdCamer float groundShadowSize = settings.shadowDistance.value; // The world space camera will be required but the global constant buffer will not be injected yet. - cb._WorldSpaceShadowCenter = new Vector2(hdCamera.camera.transform.position.x, hdCamera.camera.transform.position.z); + cb._WorldSpaceShadowCenter = new Vector4(hdCamera.camera.transform.position.x, hdCamera.camera.transform.position.y, hdCamera.camera.transform.position.z, 0.0f); if (HasVolumetricCloudsShadows(hdCamera, settings)) { diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricClouds.compute b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricClouds.compute index 46219077f81..fd6392e1dd3 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricClouds.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricClouds.compute @@ -1573,7 +1573,7 @@ void ComputeVolumetricCloudsShadow(uint3 currentCoords : SV_DispatchThreadID, ui // Compute the position of the shadow plane #ifdef LOCAL_VOLUMETRIC_CLOUDS - float3 shadowCookieCenterWS = float3(_WorldSpaceShadowCenter.x, _ShadowPlaneOffset, _WorldSpaceShadowCenter.y) + t * _SunDirection.xyz; + float3 shadowCookieCenterWS = float3(_WorldSpaceShadowCenter.x, _ShadowPlaneOffset, _WorldSpaceShadowCenter.z) + t * _SunDirection.xyz; #else float3 shadowCookieCenterWS = t * _SunDirection.xyz; #endif @@ -1612,6 +1612,10 @@ void ComputeVolumetricCloudsShadow(uint3 currentCoords : SV_DispatchThreadID, ui // Compute the cloud density CloudProperties cloudProperties; EvaluateCloudProperties(positionWS, 0.0, 0.0, true, true, cloudProperties); + + // Apply the camera fade it to match the clouds perceived by the camera + cloudProperties.density = DensityFadeIn(cloudProperties.density, length(positionWS - _WorldSpaceShadowCenter.xyz)); + if (cloudProperties.density > CLOUD_DENSITY_TRESHOLD) { // Apply the extinction diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricCloudsDef.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricCloudsDef.cs index f89139e4bc8..c4735139de8 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricCloudsDef.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricCloudsDef.cs @@ -130,9 +130,10 @@ unsafe struct ShaderVariablesClouds // The size of the shadow region (meters) public Vector2 _ShadowRegionSize; + public Vector2 _PaddingVC0; - // World Camera Position used as the constant buffer has not been injected yet when this data is required - public Vector2 _WorldSpaceShadowCenter; + // World Camera Position used as the constant buffer has not been injected yet when this data is required, last channel is unused. + public Vector4 _WorldSpaceShadowCenter; // View projection matrix (non oblique) for the planar reflection matrices public Matrix4x4 _CameraViewProjection_NO; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricCloudsDef.cs.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricCloudsDef.cs.hlsl index 80579aea9e0..d12ffbad3b0 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricCloudsDef.cs.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricCloudsDef.cs.hlsl @@ -61,7 +61,8 @@ CBUFFER_START(ShaderVariablesClouds) int _ShadowCookieResolution; float _ShadowPlaneOffset; float2 _ShadowRegionSize; - float2 _WorldSpaceShadowCenter; + float2 _PaddingVC0; + float4 _WorldSpaceShadowCenter; float4x4 _CameraViewProjection_NO; float4x4 _CameraInverseViewProjection_NO; float4x4 _CameraPrevViewProjection_NO; From 22405b07d58396b663a2d7788acac9e89e90a5a4 Mon Sep 17 00:00:00 2001 From: anisunity Date: Tue, 14 Dec 2021 10:43:46 +0100 Subject: [PATCH 2/3] Update runtime dx11 screenshot --- .../WindowsPlayer/Direct3D11/None/004-CloudsFlaresDecals.png | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TestProjects/HDRP_RuntimeTests/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D11/None/004-CloudsFlaresDecals.png b/TestProjects/HDRP_RuntimeTests/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D11/None/004-CloudsFlaresDecals.png index c1a0998f156..56cbd126da8 100644 --- a/TestProjects/HDRP_RuntimeTests/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D11/None/004-CloudsFlaresDecals.png +++ b/TestProjects/HDRP_RuntimeTests/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D11/None/004-CloudsFlaresDecals.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d826c9f312ebc195178aa0298f811a28d3af70cc1e851fa0e5a5130237a309cc -size 2319903 +oid sha256:ab84fe97f434ac7cc8c64a010195eda55f0366a02cdf4184e89d211723ca5f60 +size 2333196 From 34c6109f440033060f23ea79a11de489b06c6a03 Mon Sep 17 00:00:00 2001 From: Anis Benyoub Date: Wed, 15 Dec 2021 09:17:46 +0100 Subject: [PATCH 3/3] Update standalone screenshots --- .../Linear/LinuxPlayer/Vulkan/None/004-CloudsFlaresDecals.png | 4 ++-- .../WindowsPlayer/Direct3D12/None/004-CloudsFlaresDecals.png | 4 ++-- .../WindowsPlayer/Vulkan/None/004-CloudsFlaresDecals.png | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/TestProjects/HDRP_RuntimeTests/Assets/ReferenceImages/Linear/LinuxPlayer/Vulkan/None/004-CloudsFlaresDecals.png b/TestProjects/HDRP_RuntimeTests/Assets/ReferenceImages/Linear/LinuxPlayer/Vulkan/None/004-CloudsFlaresDecals.png index 7ccf92fa6a0..fa0e58b5986 100644 --- a/TestProjects/HDRP_RuntimeTests/Assets/ReferenceImages/Linear/LinuxPlayer/Vulkan/None/004-CloudsFlaresDecals.png +++ b/TestProjects/HDRP_RuntimeTests/Assets/ReferenceImages/Linear/LinuxPlayer/Vulkan/None/004-CloudsFlaresDecals.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:10bccf6a90d12f29fd3a55220e061100396861c6b0b5085cf1fc406f33fe3186 -size 2314436 +oid sha256:1015444c959f0540f66fa2c677a134eff6f16f0fe53822a10438ef9adf629b0e +size 2319032 diff --git a/TestProjects/HDRP_RuntimeTests/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D12/None/004-CloudsFlaresDecals.png b/TestProjects/HDRP_RuntimeTests/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D12/None/004-CloudsFlaresDecals.png index cdb6b54c34c..db794488db9 100644 --- a/TestProjects/HDRP_RuntimeTests/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D12/None/004-CloudsFlaresDecals.png +++ b/TestProjects/HDRP_RuntimeTests/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D12/None/004-CloudsFlaresDecals.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4ed49be373bdd23c89e9f4a5af188146980d6181890b02ce12294578c14c1885 -size 2320048 +oid sha256:cc6ddc5fbd302511e90e0a5c4303640b620338749ae7a3ae559d821eb5f79e43 +size 2332098 diff --git a/TestProjects/HDRP_RuntimeTests/Assets/ReferenceImages/Linear/WindowsPlayer/Vulkan/None/004-CloudsFlaresDecals.png b/TestProjects/HDRP_RuntimeTests/Assets/ReferenceImages/Linear/WindowsPlayer/Vulkan/None/004-CloudsFlaresDecals.png index dcb454649db..4b91f397daa 100644 --- a/TestProjects/HDRP_RuntimeTests/Assets/ReferenceImages/Linear/WindowsPlayer/Vulkan/None/004-CloudsFlaresDecals.png +++ b/TestProjects/HDRP_RuntimeTests/Assets/ReferenceImages/Linear/WindowsPlayer/Vulkan/None/004-CloudsFlaresDecals.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:07de7b03322e622bb67c38c898890c6f5ed09c98f2042c88861b9f42dfbf9db9 -size 2313477 +oid sha256:2e4f6eff373dba214efec1dbf26580a9b9770f928e7f7ce9c514a4de13839966 +size 2326939