From 11006baa65988d7e1bbe921681aab1e8d7d57e47 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Fri, 7 Aug 2020 15:40:35 +0200 Subject: [PATCH] [unity] Fixed URP Sprite shader treating skeleton alpha incorrectly. Closes #1735. --- .../CGIncludes/Spine-Sprite-ForwardPass-LW.hlsl | 12 ++++++------ .../Include/Spine-Sprite-ForwardPass-URP.hlsl | 13 +++++++------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-ForwardPass-LW.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-ForwardPass-LW.hlsl index 4c1e890a5..0736f78b2 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-ForwardPass-LW.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-ForwardPass-LW.hlsl @@ -75,7 +75,7 @@ half4 LightweightFragmentPBRSimplified(InputData inputData, half4 texAlbedoAlpha half4 albedo = texAlbedoAlpha * vertexColor; BRDFData brdfData; - half ignoredAlpha = 1; // ignore alpha, otherwise + half ignoredAlpha = 1; // ignore alpha, otherwise InitializeBRDFData(albedo.rgb, metallic, specular, smoothness, ignoredAlpha, brdfData); brdfData.specular *= albedo.a; @@ -105,7 +105,7 @@ half4 LightweightFragmentPBRSimplified(InputData inputData, half4 texAlbedoAlpha finalColor += inputData.vertexLighting * brdfData.diffuse; #endif finalColor += emission; - return prepareLitPixelForOutput(half4(finalColor, texAlbedoAlpha.a), vertexColor); + return prepareLitPixelForOutput(half4(finalColor, albedo.a), vertexColor); } #else // !SPECULAR @@ -148,7 +148,7 @@ half4 LightweightFragmentBlinnPhongSimplified(InputData inputData, half4 texDiff diffuseLighting += emission; //half3 finalColor = diffuseLighting * diffuse + emission; half3 finalColor = diffuseLighting * diffuse.rgb; - return prepareLitPixelForOutput(half4(finalColor, texDiffuseAlpha.a), vertexColor); + return prepareLitPixelForOutput(half4(finalColor, diffuse.a), vertexColor); } #endif // SPECULAR @@ -168,7 +168,7 @@ VertexOutputLWRP ForwardPassVertexSprite(VertexInput input) float backFaceSign = 1; #if defined(FIXED_NORMALS_BACKFACE_RENDERING) backFaceSign = calculateBackfacingSign(positionWS.xyz); -#endif +#endif output.viewDirectionWS = GetCameraPositionWS() - positionWS; #if defined(PER_PIXEL_LIGHTING) @@ -219,7 +219,7 @@ half4 ForwardPassFragmentSprite(VertexOutputLWRP input) : SV_Target #if defined(_MAIN_LIGHT_SHADOWS) && !defined(_RECEIVE_SHADOWS_OFF) inputData.shadowCoord = input.shadowCoord; #endif - + inputData.viewDirectionWS = input.viewDirectionWS; inputData.vertexLighting = input.fogFactorAndVertexLight.yzw; @@ -239,7 +239,7 @@ half4 ForwardPassFragmentSprite(VertexOutputLWRP input) : SV_Target #if defined(_RIM_LIGHTING) || defined(_ADDITIONAL_LIGHTS) inputData.positionWS = input.positionWS.rgb; #endif - + #if defined(SPECULAR) half2 metallicGloss = getMetallicGloss(input.texcoord.xy); half metallic = metallicGloss.x; diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-ForwardPass-URP.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-ForwardPass-URP.hlsl index 1be33a8d1..d4f7ccd7a 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-ForwardPass-URP.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-ForwardPass-URP.hlsl @@ -75,7 +75,7 @@ half4 LightweightFragmentPBRSimplified(InputData inputData, half4 texAlbedoAlpha half4 albedo = texAlbedoAlpha * vertexColor; BRDFData brdfData; - half ignoredAlpha = 1; // ignore alpha, otherwise + half ignoredAlpha = 1; // ignore alpha, otherwise InitializeBRDFData(albedo.rgb, metallic, specular, smoothness, ignoredAlpha, brdfData); brdfData.specular *= albedo.a; @@ -105,7 +105,7 @@ half4 LightweightFragmentPBRSimplified(InputData inputData, half4 texAlbedoAlpha finalColor += inputData.vertexLighting * brdfData.diffuse; #endif finalColor += emission; - return prepareLitPixelForOutput(half4(finalColor, texAlbedoAlpha.a), vertexColor); + return prepareLitPixelForOutput(half4(finalColor, albedo.a), vertexColor); } #else // !SPECULAR @@ -148,7 +148,7 @@ half4 LightweightFragmentBlinnPhongSimplified(InputData inputData, half4 texDiff diffuseLighting += emission; //half3 finalColor = diffuseLighting * diffuse + emission; half3 finalColor = diffuseLighting * diffuse.rgb; - return prepareLitPixelForOutput(half4(finalColor, texDiffuseAlpha.a), vertexColor); + return prepareLitPixelForOutput(half4(finalColor, diffuse.a), vertexColor); } #endif // SPECULAR @@ -168,7 +168,7 @@ VertexOutputLWRP ForwardPassVertexSprite(VertexInput input) float backFaceSign = 1; #if defined(FIXED_NORMALS_BACKFACE_RENDERING) backFaceSign = calculateBackfacingSign(positionWS.xyz); -#endif +#endif output.viewDirectionWS = GetCameraPositionWS() - positionWS; #if defined(PER_PIXEL_LIGHTING) @@ -219,7 +219,7 @@ half4 ForwardPassFragmentSprite(VertexOutputLWRP input) : SV_Target #if defined(_MAIN_LIGHT_SHADOWS) && !defined(_RECEIVE_SHADOWS_OFF) inputData.shadowCoord = input.shadowCoord; #endif - + inputData.viewDirectionWS = input.viewDirectionWS; inputData.vertexLighting = input.fogFactorAndVertexLight.yzw; @@ -239,7 +239,7 @@ half4 ForwardPassFragmentSprite(VertexOutputLWRP input) : SV_Target #if defined(_RIM_LIGHTING) || defined(_ADDITIONAL_LIGHTS) inputData.positionWS = input.positionWS.rgb; #endif - + #if defined(SPECULAR) half2 metallicGloss = getMetallicGloss(input.texcoord.xy); half metallic = metallicGloss.x; @@ -261,6 +261,7 @@ half4 ForwardPassFragmentSprite(VertexOutputLWRP input) : SV_Target COLORISE(pixel) APPLY_FOG_LWRP(pixel, input.fogFactorAndVertexLight.x) + return pixel; }