opaque.effect 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. #include "color.effect"
  2. uniform float4x4 ViewProj;
  3. uniform texture2d image;
  4. uniform float multiplier;
  5. sampler_state def_sampler {
  6. Filter = Linear;
  7. AddressU = Clamp;
  8. AddressV = Clamp;
  9. };
  10. struct VertInOut {
  11. float4 pos : POSITION;
  12. float2 uv : TEXCOORD0;
  13. };
  14. VertInOut VSDefault(VertInOut vert_in)
  15. {
  16. VertInOut vert_out;
  17. vert_out.pos = mul(float4(vert_in.pos.xyz, 1.0), ViewProj);
  18. vert_out.uv = vert_in.uv;
  19. return vert_out;
  20. }
  21. float4 PSDraw(VertInOut vert_in) : TARGET
  22. {
  23. return float4(image.Sample(def_sampler, vert_in.uv).rgb, 1.0);
  24. }
  25. float4 PSDrawSrgbDecompress(VertInOut vert_in) : TARGET
  26. {
  27. float3 rgb = image.Sample(def_sampler, vert_in.uv).rgb;
  28. rgb = srgb_nonlinear_to_linear(rgb);
  29. return float4(rgb, 1.0);
  30. }
  31. float4 PSDrawSrgbDecompressMultiply(VertInOut vert_in) : TARGET
  32. {
  33. float3 rgb = image.Sample(def_sampler, vert_in.uv).rgb;
  34. rgb = srgb_nonlinear_to_linear(rgb);
  35. rgb *= multiplier;
  36. return float4(rgb, 1.0);
  37. }
  38. float4 PSDrawMultiply(VertInOut vert_in) : TARGET
  39. {
  40. float3 rgb = image.Sample(def_sampler, vert_in.uv).rgb;
  41. rgb *= multiplier;
  42. return float4(rgb, 1.0);
  43. }
  44. float4 PSDrawTonemap(VertInOut vert_in) : TARGET
  45. {
  46. float3 rgb = image.Sample(def_sampler, vert_in.uv).rgb;
  47. rgb = rec709_to_rec2020(rgb);
  48. rgb = reinhard(rgb);
  49. rgb = rec2020_to_rec709(rgb);
  50. return float4(rgb, 1.0);
  51. }
  52. float4 PSDrawMultiplyTonemap(VertInOut vert_in) : TARGET
  53. {
  54. float3 rgb = image.Sample(def_sampler, vert_in.uv).rgb;
  55. rgb *= multiplier;
  56. rgb = rec709_to_rec2020(rgb);
  57. rgb = reinhard(rgb);
  58. rgb = rec2020_to_rec709(rgb);
  59. return float4(rgb, 1.0);
  60. }
  61. float4 PSDrawPQ(VertInOut vert_in) : TARGET
  62. {
  63. float3 rgb = image.Sample(def_sampler, vert_in.uv).rgb;
  64. rgb = st2084_to_linear(rgb) * multiplier;
  65. rgb = rec2020_to_rec709(rgb);
  66. return float4(rgb, 1.0);
  67. }
  68. float4 PSDrawTonemapPQ(VertInOut vert_in) : TARGET
  69. {
  70. float3 rgb = image.Sample(def_sampler, vert_in.uv).rgb;
  71. rgb = st2084_to_linear(rgb) * multiplier;
  72. rgb = reinhard(rgb);
  73. rgb = rec2020_to_rec709(rgb);
  74. return float4(rgb, 1.0);
  75. }
  76. technique Draw
  77. {
  78. pass
  79. {
  80. vertex_shader = VSDefault(vert_in);
  81. pixel_shader = PSDraw(vert_in);
  82. }
  83. }
  84. technique DrawSrgbDecompress
  85. {
  86. pass
  87. {
  88. vertex_shader = VSDefault(vert_in);
  89. pixel_shader = PSDrawSrgbDecompress(vert_in);
  90. }
  91. }
  92. technique DrawSrgbDecompressMultiply
  93. {
  94. pass
  95. {
  96. vertex_shader = VSDefault(vert_in);
  97. pixel_shader = PSDrawSrgbDecompressMultiply(vert_in);
  98. }
  99. }
  100. technique DrawMultiply
  101. {
  102. pass
  103. {
  104. vertex_shader = VSDefault(vert_in);
  105. pixel_shader = PSDrawMultiply(vert_in);
  106. }
  107. }
  108. technique DrawTonemap
  109. {
  110. pass
  111. {
  112. vertex_shader = VSDefault(vert_in);
  113. pixel_shader = PSDrawTonemap(vert_in);
  114. }
  115. }
  116. technique DrawMultiplyTonemap
  117. {
  118. pass
  119. {
  120. vertex_shader = VSDefault(vert_in);
  121. pixel_shader = PSDrawMultiplyTonemap(vert_in);
  122. }
  123. }
  124. technique DrawPQ
  125. {
  126. pass
  127. {
  128. vertex_shader = VSDefault(vert_in);
  129. pixel_shader = PSDrawPQ(vert_in);
  130. }
  131. }
  132. technique DrawTonemapPQ
  133. {
  134. pass
  135. {
  136. vertex_shader = VSDefault(vert_in);
  137. pixel_shader = PSDrawTonemapPQ(vert_in);
  138. }
  139. }