Spine-DepthOnlyPass-URP.hlsl 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #ifndef SPRITES_DEPTH_ONLY_PASS_URP_INCLUDED
  2. #define SPRITES_DEPTH_ONLY_PASS_URP_INCLUDED
  3. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
  4. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  5. struct AttributesSpine
  6. {
  7. float4 positionOS : POSITION;
  8. float3 normalOS : NORMAL;
  9. float4 vertexColor : COLOR;
  10. float2 texcoord : TEXCOORD0;
  11. UNITY_VERTEX_INPUT_INSTANCE_ID
  12. };
  13. struct VaryingsSpine
  14. {
  15. float4 positionCS : SV_POSITION;
  16. float4 texcoordAndAlpha: TEXCOORD0;
  17. UNITY_VERTEX_OUTPUT_STEREO
  18. };
  19. VaryingsSpine DepthOnlyVertex(AttributesSpine input)
  20. {
  21. VaryingsSpine output = (VaryingsSpine)0;
  22. UNITY_SETUP_INSTANCE_ID(input);
  23. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
  24. output.texcoordAndAlpha.xyz = float3(TRANSFORM_TEX(input.texcoord, _MainTex).xy, 0);
  25. output.texcoordAndAlpha.a = input.vertexColor.a;
  26. output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
  27. return output;
  28. }
  29. half4 DepthOnlyFragment(VaryingsSpine input) : SV_TARGET
  30. {
  31. fixed4 texureColor = tex2D(_MainTex, input.texcoordAndAlpha.xy);
  32. clip(texureColor.a * input.texcoordAndAlpha.a - _Cutoff);
  33. return 0;
  34. }
  35. #endif