Skip to content

Commit

Permalink
[Port] [2022.3] [UUM-64059] made ForwardLit and GBuffer passes of URP…
Browse files Browse the repository at this point in the history
…'s speed tree shaders have the same c-buffer layout in vertex and fragment shaders when GPU instancing and Light Layer are enabled

JIRA: [UUM-64059](https://jira.unity3d.com/browse/UUM-64059)

This PR is to fix the error case where. shader compilation error logs about c-buffer layout mispatch in vertex and fragment shaders of URP speed tree 7 shader are repetitively printed out when the material enables GPU instancing and Use Rendering Layer in URP RP asset's lighting section is on.

Because the speed tree shader is not compatible with SRP Batcher, the shader is supported by InstancingBatcher.
When rendering request comes, the batcher collects layout informations about 'unity_Builtins0Array' through array of GPU program parameters defined by shader compilation result.
For its vertex shader variant, `unity_LODFadeArray` is the first member of the c-buffer because the shader always enables `LOD_FADE_PERCENTAGE`.
In addtion to that, `unity_RenderingLayerArray` becomes the second member because Light Layer, a `multi_compile` keyword is active, 
Unlikely, for its fragment shader variant, it still requires `unity_Builtins0Array`, but the `LOD_FADE_PERCENTAGE` keyword doesn't exist here, so the first member is determined to be `unity_RenderingLayerArray`, and the mismatch case occurs.

For avoiding this, I simply changed their pragma action from `multi_compile_vertex` to `multi_compile`.
And when I tested further, there are more places where the same problem happens, I applied this there too.
So, affected places are...

- `ForwardLit` pass in URP's SpeedTree7 shader
- `GBuffer` pass in URP's SpeedTree7 shader
- `ForwardLit` pass in URP's SpeedTree8 shader
- `GBuffer` pass in URP's SpeedTree8 shader
  • Loading branch information
katana7755 authored and Evergreen committed Oct 23, 2024
1 parent 4377649 commit 0fbf1c3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Shader "Universal Render Pipeline/Nature/SpeedTree7"
#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
#pragma multi_compile_fragment _ LOD_FADE_CROSSFADE
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
#pragma multi_compile_vertex LOD_FADE_PERCENTAGE
#pragma multi_compile LOD_FADE_PERCENTAGE
#pragma multi_compile_fragment _ DEBUG_DISPLAY
#pragma multi_compile_fragment _ _LIGHT_COOKIES
#pragma multi_compile _ _LIGHT_LAYERS
Expand Down Expand Up @@ -149,7 +149,7 @@ Shader "Universal Render Pipeline/Nature/SpeedTree7"
//#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
#pragma multi_compile_fragment _ LOD_FADE_CROSSFADE
#pragma multi_compile_vertex LOD_FADE_PERCENTAGE
#pragma multi_compile LOD_FADE_PERCENTAGE
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
#pragma multi_compile_fragment _ _RENDER_PASS_ENABLED
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Shader "Universal Render Pipeline/Nature/SpeedTree8"
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
#pragma multi_compile _ _LIGHT_LAYERS
#pragma multi_compile _ _FORWARD_PLUS
#pragma multi_compile_vertex LOD_FADE_PERCENTAGE
#pragma multi_compile LOD_FADE_PERCENTAGE
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
Expand Down Expand Up @@ -140,7 +140,7 @@ Shader "Universal Render Pipeline/Nature/SpeedTree8"
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
#pragma multi_compile_fragment _ LOD_FADE_CROSSFADE
#pragma multi_compile_vertex LOD_FADE_PERCENTAGE
#pragma multi_compile LOD_FADE_PERCENTAGE
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
#pragma multi_compile_fragment _ _RENDER_PASS_ENABLED
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
Expand Down

0 comments on commit 0fbf1c3

Please sign in to comment.