CTI URP Bark ShadowCaster Pass.hlsl 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  2. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl"
  3. // Structs
  4. struct Attributes
  5. {
  6. float4 positionOS : POSITION;
  7. float3 normalOS : NORMAL;
  8. float2 texcoord1 : TEXCOORD1; // Bending
  9. half4 color : COLOR; // Bending
  10. UNITY_VERTEX_INPUT_INSTANCE_ID
  11. };
  12. struct Varyings
  13. {
  14. float4 positionCS : SV_POSITION;
  15. };
  16. // Shadow caster specific input
  17. float3 _LightDirection;
  18. float3 _LightPosition;
  19. //--------------------------------------
  20. // Vertex shader
  21. #include "Includes/CTI URP Bending.hlsl"
  22. Varyings ShadowPassVertex(Attributes input)
  23. {
  24. Varyings output = (Varyings)0;
  25. UNITY_SETUP_INSTANCE_ID(input);
  26. CTI_AnimateVertex(
  27. input,
  28. #if defined (_BENDINGCOLRSONLY)
  29. float4(input.color.rg, input.color.ab), // animParams,
  30. #else
  31. float4(input.color.rg, input.texcoord1.xy), // animParams,
  32. #endif
  33. _BaseWindMultipliers
  34. );
  35. float3 positionWS = TransformObjectToWorld(input.positionOS.xyz);
  36. float3 normalWS = TransformObjectToWorldDir(input.normalOS);
  37. #if _CASTING_PUNCTUAL_LIGHT_SHADOW
  38. float3 lightDirectionWS = normalize(_LightPosition - positionWS);
  39. #else
  40. float3 lightDirectionWS = _LightDirection;
  41. #endif
  42. output.positionCS = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, lightDirectionWS));
  43. #if UNITY_REVERSED_Z
  44. output.positionCS.z = min(output.positionCS.z, UNITY_NEAR_CLIP_VALUE);
  45. #else
  46. output.positionCS.z = max(output.positionCS.z, UNITY_NEAR_CLIP_VALUE);
  47. #endif
  48. return output;
  49. }
  50. //--------------------------------------
  51. // Fragment shader
  52. half4 ShadowPassFragment(Varyings input) : SV_Target
  53. {
  54. #if defined(LOD_FADE_CROSSFADE) && !defined(SHADER_API_GLES)
  55. LODDitheringTransition(input.positionCS.xyz, unity_LODFade.x);
  56. #endif
  57. return 0;
  58. }