|
@@ -22,11 +22,9 @@ struct VaryingsSpine
|
|
|
float4 texcoordAndAlpha: TEXCOORD0;
|
|
|
};
|
|
|
|
|
|
-float4 GetShadowPositionHClip(AttributesSpine input)
|
|
|
+float4 GetShadowPositionHClip(float3 positionOS, half3 normalWS)
|
|
|
{
|
|
|
- float3 positionWS = TransformObjectToWorld(input.positionOS.xyz);
|
|
|
- float3 normalWS = TransformObjectToWorldNormal(input.normalOS);
|
|
|
-
|
|
|
+ float3 positionWS = TransformObjectToWorld(positionOS);
|
|
|
float4 positionCS = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, _LightDirection));
|
|
|
|
|
|
#if UNITY_REVERSED_Z
|
|
@@ -44,7 +42,19 @@ VaryingsSpine ShadowPassVertexSkeletonLit(AttributesSpine input)
|
|
|
UNITY_SETUP_INSTANCE_ID(input);
|
|
|
|
|
|
output.texcoordAndAlpha.xyz = float3(TRANSFORM_TEX(input.texcoord, _MainTex).xy, 0);
|
|
|
- output.positionCS = GetShadowPositionHClip(input);
|
|
|
+
|
|
|
+ half3 fixedNormalOS = half3(0, 0, -1);
|
|
|
+ half3 normalWS = normalize(TransformObjectToWorldNormal(fixedNormalOS));
|
|
|
+#ifdef _DOUBLE_SIDED_LIGHTING
|
|
|
+ // flip normal for shadow bias if necessary
|
|
|
+ // unfortunately we have to compute the sign here in the vertex shader
|
|
|
+ // instead of using VFACE in fragment shader stage.
|
|
|
+ half3 viewDirWS = UNITY_MATRIX_V[2].xyz;
|
|
|
+ half faceSign = sign(dot(viewDirWS, normalWS));
|
|
|
+ normalWS *= faceSign;
|
|
|
+#endif
|
|
|
+
|
|
|
+ output.positionCS = GetShadowPositionHClip(input.positionOS.xyz, normalWS);
|
|
|
output.texcoordAndAlpha.a = input.vertexColor.a;
|
|
|
return output;
|
|
|
}
|