From fa712fc325ccbd4cd49a416b40d2a31cd71e8fc7 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Tue, 19 Nov 2019 17:10:35 +0100 Subject: [PATCH] [unity] Fixed `Spine/Skeleton Lit` shader not being affected by point lights. Closes #1550. Also fixed outline 4 vs 8 neighbourhood parameter being ignored (due to #pragma multi_compile / #pragma shader_feature not being evaluated in included cginc files, too late in preprocessor stage). --- .../Shaders/CGIncludes/Spine-Skeleton-Lit-Common.cginc | 9 ++++----- .../Shaders/Outline/CGIncludes/Spine-Outline-Pass.cginc | 1 - .../SkeletonGraphic/Spine-SkeletonGraphic-Outline.shader | 1 + .../Shaders/Outline/Spine-Skeleton-Outline.shader | 1 + .../spine-unity/Shaders/Spine-Skeleton-Lit-ZWrite.shader | 1 + .../spine-unity/Shaders/Spine-Skeleton-Lit.shader | 1 + 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Skeleton-Lit-Common.cginc b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Skeleton-Lit-Common.cginc index 5bec05dc4..9dc1709d4 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Skeleton-Lit-Common.cginc +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Skeleton-Lit-Common.cginc @@ -12,19 +12,18 @@ #define LIGHT_LOOP_LIMIT unity_VertexLightParams.x #endif -#pragma multi_compile __ POINT SPOT //////////////////////////////////////// // Alpha Clipping // -#if defined(_ALPHA_CLIP) +#if defined(_ALPHA_CLIP) uniform fixed _Cutoff; #define ALPHA_CLIP(pixel, color) clip((pixel.a * color.a) - _Cutoff); #else #define ALPHA_CLIP(pixel, color) -#endif - +#endif + half3 computeLighting (int idx, half3 dirToLight, half3 eyeNormal, half4 diffuseColor, half atten) { half NdotL = max(dot(eyeNormal, dirToLight), 0.0); // diffuse @@ -111,7 +110,7 @@ fixed4 frag (VertexOutput i) : SV_Target { #else col.rgb = tex * i.color; #endif - + col *= 2; col.a = tex.a * i.color.a; return col; diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Outline/CGIncludes/Spine-Outline-Pass.cginc b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Outline/CGIncludes/Spine-Outline-Pass.cginc index 2cf757ed9..7ed2a2861 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Outline/CGIncludes/Spine-Outline-Pass.cginc +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Outline/CGIncludes/Spine-Outline-Pass.cginc @@ -1,7 +1,6 @@ #ifndef SPINE_OUTLINE_PASS_INCLUDED #define SPINE_OUTLINE_PASS_INCLUDED -#pragma shader_feature _ _USE8NEIGHBOURHOOD_ON #include "UnityCG.cginc" #ifdef SKELETON_GRAPHIC diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Outline/SkeletonGraphic/Spine-SkeletonGraphic-Outline.shader b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Outline/SkeletonGraphic/Spine-SkeletonGraphic-Outline.shader index 4d6dc41f3..4497c6b83 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Outline/SkeletonGraphic/Spine-SkeletonGraphic-Outline.shader +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Outline/SkeletonGraphic/Spine-SkeletonGraphic-Outline.shader @@ -62,6 +62,7 @@ Shader "Spine/Outline/SkeletonGraphic" #pragma vertex vertOutlineGraphic #pragma fragment fragOutline #define SKELETON_GRAPHIC + #pragma shader_feature _ _USE8NEIGHBOURHOOD_ON #include "../CGIncludes/Spine-Outline-Pass.cginc" ENDCG } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Outline/Spine-Skeleton-Outline.shader b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Outline/Spine-Skeleton-Outline.shader index 124f0726e..c88717f5c 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Outline/Spine-Skeleton-Outline.shader +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Outline/Spine-Skeleton-Outline.shader @@ -38,6 +38,7 @@ Shader "Spine/Outline/Skeleton" { CGPROGRAM #pragma vertex vertOutline #pragma fragment fragOutline + #pragma shader_feature _ _USE8NEIGHBOURHOOD_ON #include "CGIncludes/Spine-Outline-Pass.cginc" ENDCG } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Spine-Skeleton-Lit-ZWrite.shader b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Spine-Skeleton-Lit-ZWrite.shader index 2f17afe12..adff025cd 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Spine-Skeleton-Lit-ZWrite.shader +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Spine-Skeleton-Lit-ZWrite.shader @@ -47,6 +47,7 @@ Shader "Spine/Skeleton Lit ZWrite" { #pragma target 2.0 #define _ALPHA_CLIP + #pragma multi_compile __ POINT SPOT #include "CGIncludes/Spine-Skeleton-Lit-Common.cginc" ENDCG diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Spine-Skeleton-Lit.shader b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Spine-Skeleton-Lit.shader index bfbebd196..40594c8be 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Spine-Skeleton-Lit.shader +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Spine-Skeleton-Lit.shader @@ -45,6 +45,7 @@ Shader "Spine/Skeleton Lit" { #pragma fragment frag #pragma target 2.0 + #pragma multi_compile __ POINT SPOT #include "CGIncludes/Spine-Skeleton-Lit-Common.cginc" ENDCG