oitFragment.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. // Do not edit.
  2. import { ShaderStore } from "../../Engines/shaderStore.js";
  3. const name = "oitFragment";
  4. const shader = `#ifdef ORDER_INDEPENDENT_TRANSPARENCY
  5. float fragDepth=gl_FragCoord.z;
  6. #ifdef ORDER_INDEPENDENT_TRANSPARENCY_16BITS
  7. uint halfFloat=packHalf2x16(vec2(fragDepth));vec2 full=unpackHalf2x16(halfFloat);fragDepth=full.x;
  8. #endif
  9. ivec2 fragCoord=ivec2(gl_FragCoord.xy);vec2 lastDepth=texelFetch(oitDepthSampler,fragCoord,0).rg;vec4 lastFrontColor=texelFetch(oitFrontColorSampler,fragCoord,0);depth.rg=vec2(-MAX_DEPTH);frontColor=lastFrontColor;backColor=vec4(0.0);
  10. #ifdef USE_REVERSE_DEPTHBUFFER
  11. float furthestDepth=-lastDepth.x;float nearestDepth=lastDepth.y;
  12. #else
  13. float nearestDepth=-lastDepth.x;float furthestDepth=lastDepth.y;
  14. #endif
  15. float alphaMultiplier=1.0-lastFrontColor.a;
  16. #ifdef USE_REVERSE_DEPTHBUFFER
  17. if (fragDepth>nearestDepth || fragDepth<furthestDepth) {
  18. #else
  19. if (fragDepth<nearestDepth || fragDepth>furthestDepth) {
  20. #endif
  21. return;}
  22. #ifdef USE_REVERSE_DEPTHBUFFER
  23. if (fragDepth<nearestDepth && fragDepth>furthestDepth) {
  24. #else
  25. if (fragDepth>nearestDepth && fragDepth<furthestDepth) {
  26. #endif
  27. depth.rg=vec2(-fragDepth,fragDepth);return;}
  28. #endif
  29. `;
  30. // Sideeffect
  31. ShaderStore.IncludesShadersStore[name] = shader;
  32. /** @internal */
  33. export const oitFragment = { name, shader };
  34. //# sourceMappingURL=oitFragment.js.map