diff --git a/com.unity.render-pipelines.universal/CHANGELOG.md b/com.unity.render-pipelines.universal/CHANGELOG.md index febb5a08ef9..bf091a2bb4f 100644 --- a/com.unity.render-pipelines.universal/CHANGELOG.md +++ b/com.unity.render-pipelines.universal/CHANGELOG.md @@ -128,6 +128,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed shaderGraph shaders to render into correct depthNormals passes when deferred rendering mode and SSAO are enabled. - Fixed ordering of subshaders in the Unlit Shader Graph, such that shader target 4.5 takes priority over 2.0. [case 1328636](https://issuetracker.unity3d.com/product/unity/issues/guid/1328636/) - Fixed issue where it will clear camera color if post processing is happening on XR [case 1324451] +- Fixed an issue where shadow artefacts appeared between cascades on Terrain Detail objects. ### Changed - Change Asset/Create/Shader/Universal Render Pipeline/Lit Shader Graph to Asset/Create/Shader Graph/URP/Lit Shader Graph diff --git a/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainDetailLitPasses.hlsl b/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainDetailLitPasses.hlsl index 4b56420fe40..6ce19a66656 100644 --- a/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainDetailLitPasses.hlsl +++ b/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainDetailLitPasses.hlsl @@ -19,13 +19,11 @@ struct Varyings DECLARE_LIGHTMAP_OR_SH(staticLightmapUV, vertexSH, 1); half4 Color : TEXCOORD2; // Vertex Color half4 LightingFog : TEXCOORD3; // Vertex Lighting, Fog Factor - #if defined(MAIN_LIGHT_CALCULATE_SHADOWS) + #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) float4 ShadowCoords : TEXCOORD4; // Shadow UVs #endif half4 NormalWS : TEXCOORD5; - #if defined(DEBUG_DISPLAY) - float3 positionWS : TEXCOORD6; - #endif + float3 PositionWS : TEXCOORD6; float4 PositionCS : SV_POSITION; // Clip Position UNITY_VERTEX_INPUT_INSTANCE_ID @@ -39,19 +37,23 @@ void InitializeInputData(Varyings input, out InputData inputData) inputData.positionCS = input.PositionCS; inputData.normalWS = half3(0, 1, 0); inputData.viewDirectionWS = half3(0, 0, 1); - #if defined(MAIN_LIGHT_CALCULATE_SHADOWS) - inputData.shadowCoord = input.ShadowCoords; + + #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) + inputData.shadowCoord = input.shadowCoord; + #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS) + inputData.shadowCoord = TransformWorldToShadowCoord(input.PositionWS); #else - inputData.shadowCoord = float4(0, 0, 0, 0); + inputData.shadowCoord = float4(0, 0, 0, 0); #endif + inputData.fogCoord = input.LightingFog.a; inputData.vertexLighting = input.LightingFog.rgb; inputData.bakedGI = SAMPLE_GI(input.staticLightmapUV, input.vertexSH, input.NormalWS.xyz); inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.PositionCS); inputData.shadowMask = SAMPLE_SHADOWMASK(input.staticLightmapUV); + inputData.positionWS = input.PositionWS; #if defined(DEBUG_DISPLAY) - inputData.positionWS = input.positionWS; inputData.uv = input.UV01; #endif } @@ -123,8 +125,8 @@ Varyings TerrainLitVertex(Attributes input) output.PositionCS = vertexInput.positionCS; // Shadow Coords - #if defined(MAIN_LIGHT_CALCULATE_SHADOWS) - output.ShadowCoords = GetShadowCoord(vertexInput); + #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) + output.ShadowCoords = GetShadowCoord(vertexInput); #endif // Vertex Lighting @@ -158,10 +160,7 @@ Varyings TerrainLitVertex(Attributes input) output.LightingFog.w = ComputeFogFactor(output.PositionCS.z); output.NormalWS.xyz = NormalWS; - - #if defined(DEBUG_DISPLAY) - output.positionWS = vertexInput.positionWS; - #endif + output.PositionWS = vertexInput.positionWS; return output; }