hbao.effect 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
  2. CCEffect %{
  3. techniques:
  4. - passes:
  5. - vert: hbao-vs
  6. frag: hbao-fs
  7. pass: hbao-pass
  8. depthStencilState:
  9. depthTest: false
  10. depthWrite: false
  11. rasterizerState:
  12. cullMode: none
  13. - vert: hbao-vs
  14. frag: blurx-fs
  15. pass: blurx-pass
  16. depthStencilState:
  17. depthTest: false
  18. depthWrite: false
  19. rasterizerState:
  20. cullMode: none
  21. - vert: hbao-vs
  22. frag: blury-fs
  23. pass: blury-pass
  24. depthStencilState:
  25. depthTest: false
  26. depthWrite: false
  27. rasterizerState:
  28. cullMode: none
  29. - vert: hbao-vs
  30. frag: combine-fs
  31. pass: combine-pass
  32. depthStencilState:
  33. depthTest: false
  34. depthWrite: false
  35. rasterizerState:
  36. cullMode: none
  37. blendState:
  38. targets:
  39. - blend: true
  40. blendSrc: zero
  41. blendDst: src_alpha
  42. blendSrcAlpha: zero
  43. blendDstAlpha: one
  44. }%
  45. CCProgram hbao-vs %{
  46. #include <./chunks/vs>
  47. }%
  48. CCProgram hbao-fs %{
  49. precision highp float;
  50. #include <chunks/hbao>
  51. #include <common/common-define>
  52. in vec2 v_uv;
  53. layout(location = 0) out vec4 fragColor;
  54. void main () {
  55. float ao = CalculateAO(v_uv);
  56. fragColor = vec4(ao, ao, ao, 1.0);
  57. }
  58. }%
  59. CCProgram blurx-fs %{
  60. precision highp float;
  61. #include <chunks/hbao>
  62. #include <common/common-define>
  63. in vec2 v_uv;
  64. layout(location = 0) out vec4 fragColor;
  65. void main () {
  66. float ao = BlurCore(v_uv, vec2(1.0, 0.0));
  67. fragColor = vec4(ao, ao, ao, 1.0);
  68. }
  69. }%
  70. CCProgram blury-fs %{
  71. precision highp float;
  72. #include <chunks/hbao>
  73. #include <common/common-define>
  74. in vec2 v_uv;
  75. layout(location = 0) out vec4 fragColor;
  76. void main () {
  77. float ao = BlurCore(v_uv, vec2(0.0, 1.0));
  78. fragColor = vec4(ao, ao, ao, 1.0);
  79. }
  80. }%
  81. CCProgram combine-fs %{
  82. precision highp float;
  83. #include <chunks/hbao>
  84. #include <common/common-define>
  85. in vec2 v_uv;
  86. layout(location = 0) out vec4 fragColor;
  87. void main () {
  88. float ao = Combine(v_uv);
  89. fragColor = vec4(1.0, 1.0, 1.0, ao);
  90. }
  91. }%