Jelajahi Sumber

[unity] Fixed URP shader compile error at Unity 2021.2 (with URP 12.0 and newer). Closes #1912. Added commented-out include references to spine-core include files using package name, to be used when spine-unity is used via UPM package.

Harald Csaszar 3 tahun lalu
induk
melakukan
dfa52de90d

+ 11 - 0
spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/2D/Spine-SkeletonLit-URP-2D.shader

@@ -112,7 +112,18 @@
 					return main;
 			#endif
 				half4 mask = SAMPLE_TEXTURE2D(_MaskTex, sampler_MaskTex, i.uv);
+			#if UNITY_VERSION  < 202120
 				return half4(CombinedShapeLightShared(half4(main.rgb, 1), mask, i.lightingUV).rgb, main.a);
+			#else
+				SurfaceData2D surfaceData;
+				InputData2D inputData;
+				surfaceData.albedo = main.rgb;
+				surfaceData.alpha = 1;
+				surfaceData.mask = mask;
+				inputData.uv = i.uv;
+				inputData.lightingUV = i.lightingUV;
+				return half4(CombinedShapeLightShared(surfaceData, inputData).rgb, main.a);
+			#endif
 			}
 
 			ENDHLSL

+ 2 - 1
spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/SpineCoreShaders/ShaderShared.cginc

@@ -1,2 +1,3 @@
 // Adapt this path accordingly if you have unpacked the Spine directory to another location.
-#include "Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/ShaderShared.cginc"
+#include "Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/ShaderShared.cginc"
+//#include "Packages/com.esotericsoftware.spine.spine-unity/Runtime/spine-unity/Shaders/Sprite/CGIncludes/ShaderShared.cginc"

+ 1 - 0
spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/SpineCoreShaders/Spine-Common.cginc

@@ -1,2 +1,3 @@
 // Adapt this path accordingly if you have unpacked the Spine directory to another location.
 #include "Assets/Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Common.cginc"
+//#include "Packages/com.esotericsoftware.spine.spine-unity/Runtime/spine-unity/Shaders/CGIncludes/Spine-Common.cginc"

+ 1 - 0
spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/SpineCoreShaders/Spine-Outline-Common.cginc

@@ -1,2 +1,3 @@
 // Adapt this path accordingly if you have unpacked the Spine directory to another location.
 #include "Assets/Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Outline-Common.cginc"
+//#include "Packages/com.esotericsoftware.spine.spine-unity/Runtime/spine-unity/Shaders/CGIncludes/Spine-Outline-Common.cginc"

+ 2 - 1
spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/SpineCoreShaders/SpriteLighting.cginc

@@ -1,2 +1,3 @@
 // Adapt this path accordingly if you have unpacked the Spine directory to another location.
-#include "Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/SpriteLighting.cginc"
+#include "Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/SpriteLighting.cginc"
+//#include "Packages/com.esotericsoftware.spine.spine-unity/Runtime/spine-unity/Shaders/Sprite/CGIncludes/SpriteLighting.cginc"