Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

BlitHDROverlay.shader 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. Shader "Hidden/Universal/BlitHDROverlay"
  2. {
  3. HLSLINCLUDE
  4. #pragma target 2.0
  5. #pragma editor_sync_compilation
  6. #pragma multi_compile_local_fragment _ HDR_COLORSPACE_CONVERSION HDR_ENCODING HDR_COLORSPACE_CONVERSION_AND_ENCODING
  7. // Core.hlsl for XR dependencies
  8. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  9. #include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"
  10. // Color.hlsl and HDROutput.hlsl for color space conversion and encoding
  11. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  12. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/HDROutput.hlsl"
  13. // DebuggingFullscreen.hlsl for URP debug draw
  14. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Debug/DebuggingFullscreen.hlsl"
  15. TEXTURE2D_X(_OverlayUITexture);
  16. float4 _HDROutputLuminanceParams;
  17. #define MinNits _HDROutputLuminanceParams.x
  18. #define MaxNits _HDROutputLuminanceParams.y
  19. #define PaperWhite _HDROutputLuminanceParams.z
  20. float4 SceneComposition(float4 color, float4 uiSample)
  21. {
  22. #if defined(HDR_COLORSPACE_CONVERSION)
  23. color.rgb = RotateRec709ToOutputSpace(color.rgb) * PaperWhite;
  24. #endif
  25. #if defined(HDR_ENCODING)
  26. color.rgb = SceneUIComposition(uiSample, color.rgb, PaperWhite, MaxNits);
  27. color.rgb = OETF(color.rgb, MaxNits);
  28. #endif
  29. return color;
  30. }
  31. float4 FragBlitHDR(Varyings input, SamplerState s)
  32. {
  33. float4 color = FragBlit(input, s);
  34. float4 uiSample = SAMPLE_TEXTURE2D_X(_OverlayUITexture, sampler_PointClamp, input.texcoord);
  35. return SceneComposition(color, uiSample);
  36. }
  37. // Specialized blit with URP debug draw support and UI overlay support for HDR output
  38. // Keep in sync with CoreBlit.shader
  39. half4 FragmentURPBlitHDR(Varyings input, SamplerState blitsampler)
  40. {
  41. half4 color = FragBlitHDR(input, blitsampler);
  42. #if defined(DEBUG_DISPLAY)
  43. half4 debugColor = 0;
  44. float2 uv = input.texcoord;
  45. if (CanDebugOverrideOutputColor(color, uv, debugColor))
  46. {
  47. return debugColor;
  48. }
  49. #endif
  50. return color;
  51. }
  52. ENDHLSL
  53. SubShader
  54. {
  55. Tags{ "RenderPipeline" = "UniversalPipeline" }
  56. // 0: Bilinear blit with debug draw support
  57. Pass
  58. {
  59. Name "BilinearDebugDraw"
  60. ZWrite Off ZTest Always Blend Off Cull Off
  61. HLSLPROGRAM
  62. #pragma vertex Vert
  63. #pragma fragment FragmentURPBlitBilinearSampler
  64. #pragma multi_compile_fragment _ DEBUG_DISPLAY
  65. half4 FragmentURPBlitBilinearSampler(Varyings input) : SV_Target
  66. {
  67. return FragmentURPBlitHDR(input, sampler_LinearClamp);
  68. }
  69. ENDHLSL
  70. }
  71. // 1: Nearest blit with debug draw support
  72. Pass
  73. {
  74. Name "NearestDebugDraw"
  75. ZWrite Off ZTest Always Blend Off Cull Off
  76. HLSLPROGRAM
  77. #pragma vertex Vert
  78. #pragma fragment FragmentURPBlitPointSampler
  79. #pragma multi_compile_fragment _ DEBUG_DISPLAY
  80. half4 FragmentURPBlitPointSampler(Varyings input) : SV_Target
  81. {
  82. return FragmentURPBlitHDR(input, sampler_PointClamp);
  83. }
  84. ENDHLSL
  85. }
  86. }
  87. Fallback Off
  88. }