Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2021.2] Fixing a shadow artefact on Terrain Detail objects #4447

Merged
merged 4 commits into from
May 27, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.universal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed depth of field pass usage on unsupported devices. [case 1327076](https://issuetracker.unity3d.com/issues/adreno-3xx-nothing-is-rendered-when-post-processing-is-enabled)
- Fixed an issue with Shader Graph Lit shaders where the normalized view direction produced incorrect lighting. [1332804]
- Fixed return values from GetStereoProjectionMatrix() and SetStereoViewMatrix(). [case 1312813](https://issuetracker.unity3d.com/issues/xr-urp-begincamerarender-method-is-lagging-behind-when-using-urp)
- 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -38,11 +36,15 @@ void InitializeInputData(Varyings input, out InputData inputData)

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 = IN.shadowCoord;
ellioman marked this conversation as resolved.
Show resolved Hide resolved
#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);
Expand All @@ -59,11 +61,9 @@ void InitializeInputData(Varyings input, out InputData inputData)
inputData.tangentToWorld;
#endif

inputData.positionWS = input.PositionWS;
#if defined(DEBUG_DISPLAY)
inputData.positionWS = input.positionWS;
inputData.uv = input.UV01;
#else
inputData.positionWS = float3(0, 0, 0);
#endif
}

Expand Down Expand Up @@ -134,8 +134,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
Expand Down Expand Up @@ -169,10 +169,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;
}
Expand Down