CompositeOITFS.js 1.0 KB

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