No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CoreBlit.shader 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. Shader "Hidden/Universal/CoreBlit"
  2. {
  3. HLSLINCLUDE
  4. #pragma target 2.0
  5. #pragma editor_sync_compilation
  6. // Core.hlsl for XR dependencies
  7. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  8. #include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"
  9. // DebuggingFullscreen.hlsl for URP debug draw
  10. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Debug/DebuggingFullscreen.hlsl"
  11. // Color.hlsl for color space conversion
  12. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  13. // Specialized blit with URP debug draw support and color space conversion support
  14. // Keep in sync with BlitHDROverlay.shader
  15. half4 FragmentURPBlit(Varyings input, SamplerState blitsampler)
  16. {
  17. half4 color = FragBlit(input, blitsampler);
  18. #ifdef _LINEAR_TO_SRGB_CONVERSION
  19. color = LinearToSRGB(color);
  20. #endif
  21. #if defined(DEBUG_DISPLAY)
  22. half4 debugColor = 0;
  23. float2 uv = input.texcoord;
  24. if (CanDebugOverrideOutputColor(color, uv, debugColor))
  25. {
  26. return debugColor;
  27. }
  28. #endif
  29. return color;
  30. }
  31. ENDHLSL
  32. SubShader
  33. {
  34. Tags{ "RenderPipeline" = "UniversalPipeline" }
  35. // Note: Keep shader pass names in sync with the ShaderPassNames enum in Blitter.cs
  36. // 0: Nearest
  37. Pass
  38. {
  39. ZWrite Off ZTest Always Blend Off Cull Off
  40. Name "Nearest"
  41. HLSLPROGRAM
  42. #pragma vertex Vert
  43. #pragma fragment FragNearest
  44. ENDHLSL
  45. }
  46. // 1: Bilinear
  47. Pass
  48. {
  49. ZWrite Off ZTest Always Blend Off Cull Off
  50. Name "Bilinear"
  51. HLSLPROGRAM
  52. #pragma vertex Vert
  53. #pragma fragment FragBilinear
  54. ENDHLSL
  55. }
  56. // 2: Nearest quad
  57. Pass
  58. {
  59. ZWrite Off ZTest Always Blend Off Cull Off
  60. Name "NearestQuad"
  61. HLSLPROGRAM
  62. #pragma vertex VertQuad
  63. #pragma fragment FragNearest
  64. ENDHLSL
  65. }
  66. // 3: Bilinear quad
  67. Pass
  68. {
  69. ZWrite Off ZTest Always Blend Off Cull Off
  70. Name "BilinearQuad"
  71. HLSLPROGRAM
  72. #pragma vertex VertQuad
  73. #pragma fragment FragBilinear
  74. ENDHLSL
  75. }
  76. // 4: Nearest quad with padding
  77. Pass
  78. {
  79. ZWrite Off ZTest Always Blend Off Cull Off
  80. Name "NearestQuadPadding"
  81. HLSLPROGRAM
  82. #pragma vertex VertQuadPadding
  83. #pragma fragment FragNearest
  84. ENDHLSL
  85. }
  86. // 5: Bilinear quad with padding
  87. Pass
  88. {
  89. ZWrite Off ZTest Always Blend Off Cull Off
  90. Name "BilinearQuadPadding"
  91. HLSLPROGRAM
  92. #pragma vertex VertQuadPadding
  93. #pragma fragment FragBilinear
  94. ENDHLSL
  95. }
  96. // 6: Nearest quad with padding and repeat
  97. Pass
  98. {
  99. ZWrite Off ZTest Always Blend Off Cull Off
  100. Name "NearestQuadPaddingRepeat"
  101. HLSLPROGRAM
  102. #pragma vertex VertQuadPadding
  103. #pragma fragment FragNearestRepeat
  104. ENDHLSL
  105. }
  106. // 7: Bilinear quad with padding and repeat
  107. Pass
  108. {
  109. ZWrite Off ZTest Always Blend Off Cull Off
  110. Name "BilinearQuadPaddingRepeat"
  111. HLSLPROGRAM
  112. #pragma vertex VertQuadPadding
  113. #pragma fragment FragBilinearRepeat
  114. ENDHLSL
  115. }
  116. // 8: Bilinear quad with padding (for OctahedralTexture)
  117. Pass
  118. {
  119. ZWrite Off ZTest Always Blend Off Cull Off
  120. Name "BilinearQuadPaddingOctahedral"
  121. HLSLPROGRAM
  122. #pragma vertex VertQuadPadding
  123. #pragma fragment FragOctahedralBilinearRepeat
  124. ENDHLSL
  125. }
  126. /// Version 4, 5, 6, 7 with Alpha Blending 0.5
  127. // 9: Nearest quad with padding alpha blend (4 with alpha blend)
  128. Pass
  129. {
  130. ZWrite Off ZTest Always Blend DstColor Zero Cull Off
  131. Name "NearestQuadPaddingAlphaBlend"
  132. HLSLPROGRAM
  133. #pragma vertex VertQuadPadding
  134. #pragma fragment FragNearest
  135. #define WITH_ALPHA_BLEND
  136. ENDHLSL
  137. }
  138. // 10: Bilinear quad with padding alpha blend (5 with alpha blend)
  139. Pass
  140. {
  141. ZWrite Off ZTest Always Blend DstColor Zero Cull Off
  142. Name "BilinearQuadPaddingAlphaBlend"
  143. HLSLPROGRAM
  144. #pragma vertex VertQuadPadding
  145. #pragma fragment FragBilinear
  146. #define WITH_ALPHA_BLEND
  147. ENDHLSL
  148. }
  149. // 11: Nearest quad with padding alpha blend repeat (6 with alpha blend)
  150. Pass
  151. {
  152. ZWrite Off ZTest Always Blend DstColor Zero Cull Off
  153. Name "NearestQuadPaddingAlphaBlendRepeat"
  154. HLSLPROGRAM
  155. #pragma vertex VertQuadPadding
  156. #pragma fragment FragNearestRepeat
  157. #define WITH_ALPHA_BLEND
  158. ENDHLSL
  159. }
  160. // 12: Bilinear quad with padding alpha blend repeat (7 with alpha blend)
  161. Pass
  162. {
  163. ZWrite Off ZTest Always Blend DstColor Zero Cull Off
  164. Name "BilinearQuadPaddingAlphaBlendRepeat"
  165. HLSLPROGRAM
  166. #pragma vertex VertQuadPadding
  167. #pragma fragment FragBilinearRepeat
  168. #define WITH_ALPHA_BLEND
  169. ENDHLSL
  170. }
  171. // 13: Bilinear quad with padding alpha blend (for OctahedralTexture) (8 with alpha blend)
  172. Pass
  173. {
  174. ZWrite Off ZTest Always Blend DstColor Zero Cull Off
  175. Name "BilinearQuadPaddingAlphaBlendOctahedral"
  176. HLSLPROGRAM
  177. #pragma vertex VertQuadPadding
  178. #pragma fragment FragOctahedralBilinearRepeat
  179. #define WITH_ALPHA_BLEND
  180. ENDHLSL
  181. }
  182. // 14. Project Cube to Octahedral 2d quad
  183. Pass
  184. {
  185. ZWrite Off ZTest Always Blend Off Cull Off
  186. Name "CubeToOctahedral"
  187. HLSLPROGRAM
  188. #pragma vertex VertQuad
  189. #pragma fragment FragOctahedralProject
  190. ENDHLSL
  191. }
  192. // 15. Project Cube to Octahedral 2d quad with luminance (grayscale), RGBA to YYYY
  193. Pass
  194. {
  195. ZWrite Off ZTest Always Blend Off Cull Off
  196. Name "CubeToOctahedralLuminance"
  197. HLSLPROGRAM
  198. #pragma vertex VertQuad
  199. #pragma fragment FragOctahedralProjectLuminance
  200. ENDHLSL
  201. }
  202. // 16. Project Cube to Octahedral 2d quad with with A to RGBA (AAAA)
  203. Pass
  204. {
  205. ZWrite Off ZTest Always Blend Off Cull Off
  206. Name "CubeToOctahedralAlpha"
  207. HLSLPROGRAM
  208. #pragma vertex VertQuad
  209. #pragma fragment FragOctahedralProjectAlphaToRGBA
  210. ENDHLSL
  211. }
  212. // 17. Project Cube to Octahedral 2d quad with with R to RGBA (RRRR)
  213. Pass
  214. {
  215. ZWrite Off ZTest Always Blend Off Cull Off
  216. Name "CubeToOctahedralRed"
  217. HLSLPROGRAM
  218. #pragma vertex VertQuad
  219. #pragma fragment FragOctahedralProjectRedToRGBA
  220. ENDHLSL
  221. }
  222. // 18. Bilinear quad with luminance (grayscale), RGBA to YYYY
  223. Pass
  224. {
  225. ZWrite Off ZTest Always Blend Off Cull Off
  226. Name "BilinearQuadLuminance"
  227. HLSLPROGRAM
  228. #pragma vertex VertQuad
  229. #pragma fragment FragBilinearLuminance
  230. ENDHLSL
  231. }
  232. // 19. Bilinear quad with A to RGBA (AAAA)
  233. Pass
  234. {
  235. ZWrite Off ZTest Always Blend Off Cull Off
  236. Name "BilinearQuadAlpha"
  237. HLSLPROGRAM
  238. #pragma vertex VertQuad
  239. #pragma fragment FragBilinearAlphaToRGBA
  240. ENDHLSL
  241. }
  242. // 20. Bilinear quad with R to RGBA (RRRR)
  243. Pass
  244. {
  245. ZWrite Off ZTest Always Blend Off Cull Off
  246. Name "BilinearQuadRed"
  247. HLSLPROGRAM
  248. #pragma vertex VertQuad
  249. #pragma fragment FragBilinearRedToRGBA
  250. ENDHLSL
  251. }
  252. // 21. Nearest project cube to octahedral 2d quad with padding
  253. Pass
  254. {
  255. ZWrite Off ZTest Always Blend Off Cull Off
  256. Name "NearestCubeToOctahedralPadding"
  257. HLSLPROGRAM
  258. #pragma multi_compile_local _ BLIT_DECODE_HDR
  259. #pragma vertex VertQuadPadding
  260. #pragma fragment FragOctahedralProjectNearestRepeat
  261. ENDHLSL
  262. }
  263. // 22. Bilinear project cube to octahedral 2d quad with padding
  264. Pass
  265. {
  266. ZWrite Off ZTest Always Blend Off Cull Off
  267. Name "BilinearCubeToOctahedralPadding"
  268. HLSLPROGRAM
  269. #pragma multi_compile_local _ BLIT_DECODE_HDR
  270. #pragma vertex VertQuadPadding
  271. #pragma fragment FragOctahedralProjectBilinearRepeat
  272. ENDHLSL
  273. }
  274. // 23: Bilinear blit with debug draw and color space conversion support
  275. Pass
  276. {
  277. Name "BilinearDebugDraw"
  278. ZWrite Off ZTest Always Blend Off Cull Off
  279. HLSLPROGRAM
  280. #pragma vertex Vert
  281. #pragma fragment FragmentURPBlitBilinearSampler
  282. #pragma multi_compile_fragment _ _LINEAR_TO_SRGB_CONVERSION
  283. #pragma multi_compile_fragment _ DEBUG_DISPLAY
  284. half4 FragmentURPBlitBilinearSampler(Varyings input) : SV_Target
  285. {
  286. return FragmentURPBlit(input, sampler_LinearClamp);
  287. }
  288. ENDHLSL
  289. }
  290. // 24: Nearest blit with debug draw and color space conversion support
  291. Pass
  292. {
  293. Name "NearestDebugDraw"
  294. ZWrite Off ZTest Always Blend Off Cull Off
  295. HLSLPROGRAM
  296. #pragma vertex Vert
  297. #pragma fragment FragmentURPBlitPointSampler
  298. #pragma multi_compile_fragment _ _LINEAR_TO_SRGB_CONVERSION
  299. #pragma multi_compile_fragment _ DEBUG_DISPLAY
  300. half4 FragmentURPBlitPointSampler(Varyings input) : SV_Target
  301. {
  302. return FragmentURPBlit(input, sampler_PointClamp);
  303. }
  304. ENDHLSL
  305. }
  306. }
  307. Fallback Off
  308. }