Без опису
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. Shader "Hidden/Universal Render Pipeline/ScreenSpaceShadows"
  2. {
  3. SubShader
  4. {
  5. Tags{ "RenderPipeline" = "UniversalPipeline" "IgnoreProjector" = "True"}
  6. HLSLINCLUDE
  7. //Keep compiler quiet about Shadows.hlsl.
  8. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
  9. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/EntityLighting.hlsl"
  10. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/ImageBasedLighting.hlsl"
  11. // Core.hlsl for XR dependencies
  12. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  13. #include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"
  14. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl"
  15. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"
  16. half4 Fragment(Varyings input) : SV_Target
  17. {
  18. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
  19. #if UNITY_REVERSED_Z
  20. float deviceDepth = SAMPLE_TEXTURE2D_X(_CameraDepthTexture, sampler_PointClamp, input.texcoord.xy).r;
  21. #else
  22. float deviceDepth = SAMPLE_TEXTURE2D_X(_CameraDepthTexture, sampler_PointClamp, input.texcoord.xy).r;
  23. deviceDepth = deviceDepth * 2.0 - 1.0;
  24. #endif
  25. //Fetch shadow coordinates for cascade.
  26. float3 wpos = ComputeWorldSpacePosition(input.texcoord.xy, deviceDepth, unity_MatrixInvVP);
  27. float4 coords = TransformWorldToShadowCoord(wpos);
  28. // Screenspace shadowmap is only used for directional lights which use orthogonal projection.
  29. half realtimeShadow = MainLightRealtimeShadow(coords);
  30. return realtimeShadow;
  31. }
  32. ENDHLSL
  33. Pass
  34. {
  35. Name "ScreenSpaceShadows"
  36. ZTest Always
  37. ZWrite Off
  38. Cull Off
  39. HLSLPROGRAM
  40. #pragma multi_compile _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE
  41. #pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
  42. #pragma vertex Vert
  43. #pragma fragment Fragment
  44. ENDHLSL
  45. }
  46. }
  47. }