tone-mapping.effect 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
  2. CCEffect %{
  3. techniques:
  4. - passes:
  5. - vert: vs
  6. frag: fs-tonemap
  7. pass: cc-tone-mapping
  8. rasterizerState:
  9. cullMode: none
  10. depthStencilState:
  11. depthTest: false
  12. depthWrite: false
  13. - vert: vs
  14. frag: fs-copy
  15. pass: cc-tone-mapping
  16. rasterizerState:
  17. cullMode: none
  18. depthStencilState:
  19. depthTest: false
  20. depthWrite: false
  21. }%
  22. CCProgram vs %{
  23. #include <./chunks/vs1>
  24. }%
  25. CCProgram fs-tonemap %{
  26. precision highp float;
  27. #include <common/color/gamma>
  28. #include <common/color/tone-mapping>
  29. in vec2 v_uv;
  30. #pragma rate inputTexture pass
  31. uniform sampler2D inputTexture;
  32. layout(location = 0) out vec4 fragColor;
  33. void main () {
  34. fragColor = texture(inputTexture, v_uv);
  35. #if CC_USE_FLOAT_OUTPUT
  36. fragColor.rgb = HDRToLDR(fragColor.rgb);
  37. fragColor.rgb = LinearToSRGB(fragColor.rgb);
  38. #endif
  39. }
  40. }%
  41. CCProgram fs-copy %{
  42. precision highp float;
  43. in vec2 v_uv;
  44. #pragma rate inputTexture pass
  45. uniform sampler2D inputTexture;
  46. layout(location = 0) out vec4 fragColor;
  47. void main () {
  48. fragColor = texture(inputTexture, v_uv);
  49. }
  50. }%