ARShadow URP.shader 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. Shader "Imagine/ARShadowURP"
  2. {
  3. Properties
  4. {
  5. _ShadowIntensity ("Intensity", Range (0, 1)) = 0.75
  6. }
  7. SubShader
  8. {
  9. PackageRequirements
  10. {
  11. "com.unity.render-pipelines.universal": "12.1.6"
  12. }
  13. Tags
  14. {
  15. "RenderPipeline"="UniversalPipeline"
  16. "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"
  17. }
  18. Pass
  19. {
  20. Name "ForwardLit"
  21. Tags { "LightMode" = "UniversalForward" }
  22. //Blend DstColor Zero, Zero One
  23. Blend SrcAlpha OneMinusSrcAlpha
  24. Cull Back
  25. //ZTest LEqual
  26. //ZWrite Off
  27. HLSLPROGRAM
  28. #pragma vertex vert
  29. #pragma fragment frag
  30. //#pragma prefer_hlslcc gles
  31. //#pragma exclude_renderers d3d11_9x
  32. //#pragma target 2.0
  33. #pragma multi_compile _ _MAIN_LIGHT_SHADOWS
  34. #pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
  35. #pragma multi_compile _ _SHADOWS_SOFT
  36. #pragma multi_compile_fog
  37. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  38. CBUFFER_START(UnityPerMaterial)
  39. float _ShadowIntensity;
  40. CBUFFER_END
  41. struct Attributes
  42. {
  43. float4 positionOS : POSITION;
  44. UNITY_VERTEX_INPUT_INSTANCE_ID
  45. };
  46. struct Varyings
  47. {
  48. float4 positionCS : SV_POSITION;
  49. float3 positionWS : TEXCOORD0;
  50. float fogCoord : TEXCOORD1;
  51. UNITY_VERTEX_INPUT_INSTANCE_ID
  52. UNITY_VERTEX_OUTPUT_STEREO
  53. };
  54. Varyings vert (Attributes input)
  55. {
  56. Varyings output = (Varyings)0;
  57. UNITY_SETUP_INSTANCE_ID(input);
  58. UNITY_TRANSFER_INSTANCE_ID(input, output);
  59. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
  60. VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
  61. output.positionCS = vertexInput.positionCS;
  62. output.positionWS = vertexInput.positionWS;
  63. output.fogCoord = ComputeFogFactor(vertexInput.positionCS.z);
  64. return output;
  65. }
  66. half4 frag (Varyings input) : SV_Target
  67. {
  68. UNITY_SETUP_INSTANCE_ID(input);
  69. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
  70. half4 color = half4(1,1,1,1);
  71. VertexPositionInputs vertexInput = (VertexPositionInputs)0;
  72. vertexInput.positionWS = input.positionWS;
  73. float4 shadowCoord = GetShadowCoord(vertexInput);
  74. half shadowAttenutation = MainLightRealtimeShadow(shadowCoord);
  75. return half4(0,0,0, (1-shadowAttenutation) * _ShadowIntensity);
  76. }
  77. ENDHLSL
  78. }
  79. }
  80. }