Spine-Sprite-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 "Include/Spine-Sprite-Common-URP.hlsl"
  4. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  5. struct AttributesSprite
  6. {
  7. float4 positionOS : POSITION;
  8. float4 vertexColor : COLOR;
  9. float2 texcoord : TEXCOORD0;
  10. UNITY_VERTEX_INPUT_INSTANCE_ID
  11. };
  12. struct VaryingsSprite
  13. {
  14. float4 positionCS : SV_POSITION;
  15. float4 texcoordAndAlpha: TEXCOORD0;
  16. UNITY_VERTEX_INPUT_INSTANCE_ID
  17. UNITY_VERTEX_OUTPUT_STEREO
  18. };
  19. VaryingsSprite DepthOnlyVertexSprite(AttributesSprite input)
  20. {
  21. VaryingsSprite output = (VaryingsSprite)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 * _Color.a;
  26. output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
  27. return output;
  28. }
  29. half4 DepthOnlyFragmentSprite(VaryingsSprite input) : SV_TARGET
  30. {
  31. fixed4 texureColor = calculateTexturePixel(input.texcoordAndAlpha.xy);
  32. clip(texureColor.a * input.texcoordAndAlpha.a - _Cutoff);
  33. return 0;
  34. }
  35. #endif