Bloom.shader 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. // Copyright (C) 2015, 2016 Keijiro Takahashi
  2. //
  3. // Permission is hereby granted, free of charge, to any person obtaining a copy
  4. // of this software and associated documentation files (the "Software"), to deal
  5. // in the Software without restriction, including without limitation the rights
  6. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. // copies of the Software, and to permit persons to whom the Software is
  8. // furnished to do so, subject to the following conditions:
  9. //
  10. // The above copyright notice and this permission notice shall be included in
  11. // all copies or substantial portions of the Software.
  12. //
  13. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. // THE SOFTWARE.
  20. //
  21. Shader "Hidden/Max820/Bloom"
  22. {
  23. Properties
  24. {
  25. _MainTex("", 2D) = "" {}
  26. _BaseTex("", 2D) = "" {}
  27. }
  28. SubShader
  29. {
  30. // 0: Prefilter
  31. Pass
  32. {
  33. ZTest Always Cull Off ZWrite Off
  34. CGPROGRAM
  35. #pragma multi_compile _ UNITY_COLORSPACE_GAMMA
  36. #include "Bloom.cginc"
  37. #pragma vertex vert
  38. #pragma fragment frag_prefilter
  39. #pragma target 3.0
  40. ENDCG
  41. }
  42. // 1: Prefilter with anti-flicker
  43. Pass
  44. {
  45. ZTest Always Cull Off ZWrite Off
  46. CGPROGRAM
  47. #define ANTI_FLICKER 1
  48. #pragma multi_compile _ UNITY_COLORSPACE_GAMMA
  49. #include "Bloom.cginc"
  50. #pragma vertex vert
  51. #pragma fragment frag_prefilter
  52. #pragma target 3.0
  53. ENDCG
  54. }
  55. // 2: First level downsampler
  56. Pass
  57. {
  58. ZTest Always Cull Off ZWrite Off
  59. CGPROGRAM
  60. #include "Bloom.cginc"
  61. #pragma vertex vert
  62. #pragma fragment frag_downsample1
  63. #pragma target 3.0
  64. ENDCG
  65. }
  66. // 3: First level downsampler with anti-flicker
  67. Pass
  68. {
  69. ZTest Always Cull Off ZWrite Off
  70. CGPROGRAM
  71. #define ANTI_FLICKER 1
  72. #include "Bloom.cginc"
  73. #pragma vertex vert
  74. #pragma fragment frag_downsample1
  75. #pragma target 3.0
  76. ENDCG
  77. }
  78. // 4: Second level downsampler
  79. Pass
  80. {
  81. ZTest Always Cull Off ZWrite Off
  82. CGPROGRAM
  83. #include "Bloom.cginc"
  84. #pragma vertex vert
  85. #pragma fragment frag_downsample2
  86. #pragma target 3.0
  87. ENDCG
  88. }
  89. // 5: Upsampler
  90. Pass
  91. {
  92. ZTest Always Cull Off ZWrite Off
  93. CGPROGRAM
  94. #include "Bloom.cginc"
  95. #pragma vertex vert_multitex
  96. #pragma fragment frag_upsample
  97. #pragma target 3.0
  98. ENDCG
  99. }
  100. // 6: High quality upsampler
  101. Pass
  102. {
  103. ZTest Always Cull Off ZWrite Off
  104. CGPROGRAM
  105. #define HIGH_QUALITY 1
  106. #include "Bloom.cginc"
  107. #pragma vertex vert_multitex
  108. #pragma fragment frag_upsample
  109. #pragma target 3.0
  110. ENDCG
  111. }
  112. // 7: Combiner
  113. Pass
  114. {
  115. ZTest Always Cull Off ZWrite Off
  116. CGPROGRAM
  117. #pragma multi_compile _ UNITY_COLORSPACE_GAMMA
  118. #include "Bloom.cginc"
  119. #pragma vertex vert_multitex
  120. #pragma fragment frag_upsample_final
  121. #pragma target 3.0
  122. ENDCG
  123. }
  124. // 8: High quality combiner
  125. Pass
  126. {
  127. ZTest Always Cull Off ZWrite Off
  128. CGPROGRAM
  129. #define HIGH_QUALITY 1
  130. #pragma multi_compile _ UNITY_COLORSPACE_GAMMA
  131. #include "Bloom.cginc"
  132. #pragma vertex vert_multitex
  133. #pragma fragment frag_upsample_final
  134. #pragma target 3.0
  135. ENDCG
  136. }
  137. }
  138. }