Unity-Technologies / com.unity.toonshader

Unity Toon Shader ( an experimental package )
Other
1.07k stars 169 forks source link

Shader compile error on HDRP 2023.2+ #359

Closed riina closed 2 months ago

riina commented 2 months ago

Describe the bug Toon shader has a compiler error on HDRP with 2023.2 and above. Observed on 2023.2.0f1, 2023.2.20f1, 6000.0.5f1

To Reproduce Steps to reproduce the behavior: Install com.unity.toonshader on any release version of 2023.2 or 6000.0

Expected behavior No shader compiler errors.

Screenshots

Shader error in 'Toon': invalid subscript 'splineVisibility' at com.unity.toonshader/Runtime/HDRP/Shaders/ShaderPassForwardUTS.hlsl(224) (on d3d11)

Shader error in 'Toon(Tessellation)': invalid subscript 'splineVisibility' at com.unity.toonshader/Runtime/HDRP/Shaders/ShaderPassForwardUTS.hlsl(224) (on d3d11)

Desktop (please complete the following information):

Additional context Shader sets LightLoopContext.splineVisibility to prevent errors about incomplete initialization, but this member was removed in a 2023.2 alpha release. The member is present in the last 2023.1 release (2023.1.20f1) and is no longer present starting with 2023.2.0f1.

This can be fixed by adjusting the preprocessor condition:

diff --git a/com.unity.toonshader/Runtime/HDRP/Shaders/ShaderPassForwardUTS.hlsl b/com.unity.toonshader/Runtime/HDRP/Shaders/ShaderPassForwardUTS.hlsl
index 1cea6d9e0..fa2769551 100644
--- a/com.unity.toonshader/Runtime/HDRP/Shaders/ShaderPassForwardUTS.hlsl
+++ b/com.unity.toonshader/Runtime/HDRP/Shaders/ShaderPassForwardUTS.hlsl
@@ -220,7 +220,7 @@ void Frag(PackedVaryingsToPS packedInput,
     context.shadowContext = InitShadowContext();
     context.shadowValue = 1;
     context.sampleReflection = 0;
-#if    VERSION_GREATER_EQUAL (12, 1 )
+#if    UNITY_VERSION >= 202120 && UNITY_VERSION < 202320
     context.splineVisibility = -1;
 #endif
 #ifdef APPLY_FOG_ON_SKY_REFLECTIONS

(commit here)

Version.hlsl in SRP Core states its numbering system using VERSION_GREATER_EQUAL and such is deprecated for SRP packages that are paired as core packages with Editor versions, as is the case for 2021.2, and to use UNITY_VERSION instead, so this change does so. Please note, the format of UNITY_VERSION changes in Unity 6.

H3idi-X commented 2 months ago

Thank you very much for the detailed information. We confirmed the issue. We will apply your fix and create test programs for release.