depth-merge.frag.ts 587 B

123456789101112131415161718192021222324
  1. export default `
  2. precision highp float;
  3. precision highp sampler2D;
  4. uniform sampler2D tDepthPrimitives;
  5. uniform sampler2D tDepthVolumes;
  6. uniform vec2 uTexSize;
  7. #include common
  8. float getDepth(const in vec2 coords, sampler2D tDepth) {
  9. #ifdef dPackedDepth
  10. return unpackRGBAToDepth(texture2D(tDepth, coords));
  11. #else
  12. return texture2D(tDepth, coords).r;
  13. #endif
  14. }
  15. void main() {
  16. vec2 coords = gl_FragCoord.xy / uTexSize;
  17. float depth = min(getDepth(coords, tDepthPrimitives), getDepth(coords, tDepthVolumes));
  18. gl_FragColor = packDepthToRGBA(depth);
  19. }
  20. `;