Spine-Common-ShadowCasterPass-URP.hlsl 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #ifndef COMMON_SHADOW_CASTER_PASS_URP_INCLUDED
  2. #define COMMON_SHADOW_CASTER_PASS_URP_INCLUDED
  3. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  4. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl"
  5. float3 _LightDirection;
  6. struct AttributesSpine
  7. {
  8. float4 positionOS : POSITION;
  9. float3 normalOS : NORMAL;
  10. float4 vertexColor : COLOR;
  11. float2 texcoord : TEXCOORD0;
  12. UNITY_VERTEX_INPUT_INSTANCE_ID
  13. };
  14. struct VaryingsSpine
  15. {
  16. float4 positionCS : SV_POSITION;
  17. float4 texcoordAndAlpha: TEXCOORD0;
  18. };
  19. float4 GetShadowPositionHClip(AttributesSpine input)
  20. {
  21. float3 positionWS = TransformObjectToWorld(input.positionOS.xyz);
  22. float3 normalWS = TransformObjectToWorldNormal(input.normalOS);
  23. float4 positionCS = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, _LightDirection));
  24. #if UNITY_REVERSED_Z
  25. positionCS.z = min(positionCS.z, positionCS.w * UNITY_NEAR_CLIP_VALUE);
  26. #else
  27. positionCS.z = max(positionCS.z, positionCS.w * UNITY_NEAR_CLIP_VALUE);
  28. #endif
  29. return positionCS;
  30. }
  31. #endif