Spine-DepthOnlyPass.cginc 920 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef SPRITES_DEPTH_ONLY_PASS_INCLUDED
  2. #define SPRITES_DEPTH_ONLY_PASS_INCLUDED
  3. #include "UnityCG.cginc"
  4. sampler2D _MainTex;
  5. float _Cutoff;
  6. float _ZWriteOffset;
  7. struct VertexInput {
  8. float4 positionOS : POSITION;
  9. float2 texcoord : TEXCOORD0;
  10. float4 vertexColor : COLOR;
  11. };
  12. struct VertexOutput {
  13. float4 positionCS : SV_POSITION;
  14. float4 texcoordAndAlpha: TEXCOORD0;
  15. };
  16. VertexOutput DepthOnlyVertex (VertexInput v) {
  17. VertexOutput o;
  18. o.positionCS = UnityObjectToClipPos(v.positionOS - float4(0, 0, _ZWriteOffset, 0));
  19. o.texcoordAndAlpha.xy = v.texcoord;
  20. o.texcoordAndAlpha.z = 0;
  21. o.texcoordAndAlpha.a = v.vertexColor.a;
  22. return o;
  23. }
  24. float4 DepthOnlyFragment (VertexOutput input) : SV_Target{
  25. float4 texColor = tex2D(_MainTex, input.texcoordAndAlpha.rg);
  26. #if defined(_STRAIGHT_ALPHA_INPUT)
  27. texColor.rgb *= texColor.a;
  28. #endif
  29. clip(texColor.a * input.texcoordAndAlpha.a - _Cutoff);
  30. return 0;
  31. }
  32. #endif