CompositeOITFS.js 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. //This file is automatically rebuilt by the Cesium build process.
  2. /*global define*/
  3. define(function() {
  4. "use strict";
  5. return "/**\n\
  6. * Compositing for Weighted Blended Order-Independent Transparency. See:\n\
  7. * - http://jcgt.org/published/0002/02/09/\n\
  8. * - http://casual-effects.blogspot.com/2014/03/weighted-blended-order-independent.html\n\
  9. */\n\
  10. \n\
  11. uniform sampler2D u_opaque;\n\
  12. uniform sampler2D u_accumulation;\n\
  13. uniform sampler2D u_revealage;\n\
  14. \n\
  15. varying vec2 v_textureCoordinates;\n\
  16. \n\
  17. void main()\n\
  18. {\n\
  19. vec4 opaque = texture2D(u_opaque, v_textureCoordinates);\n\
  20. vec4 accum = texture2D(u_accumulation, v_textureCoordinates);\n\
  21. float r = texture2D(u_revealage, v_textureCoordinates).r;\n\
  22. \n\
  23. #ifdef MRT\n\
  24. vec4 transparent = vec4(accum.rgb / clamp(r, 1e-4, 5e4), accum.a);\n\
  25. #else\n\
  26. vec4 transparent = vec4(accum.rgb / clamp(accum.a, 1e-4, 5e4), r);\n\
  27. #endif\n\
  28. \n\
  29. gl_FragColor = (1.0 - transparent.a) * transparent + transparent.a * opaque;\n\
  30. }\n\
  31. ";
  32. });