UnpackDepthRGBAShader.js 676 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. * Unpack RGBA depth shader
  3. * - show RGBA encoded depth as monochrome color
  4. */
  5. const UnpackDepthRGBAShader = {
  6. uniforms: {
  7. 'tDiffuse': { value: null },
  8. 'opacity': { value: 1.0 }
  9. },
  10. vertexShader: /* glsl */`
  11. varying vec2 vUv;
  12. void main() {
  13. vUv = uv;
  14. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  15. }`,
  16. fragmentShader: /* glsl */`
  17. uniform float opacity;
  18. uniform sampler2D tDiffuse;
  19. varying vec2 vUv;
  20. #include <packing>
  21. void main() {
  22. float depth = 1.0 - unpackRGBAToDepth( texture2D( tDiffuse, vUv ) );
  23. gl_FragColor = vec4( vec3( depth ), opacity );
  24. }`
  25. };
  26. export { UnpackDepthRGBAShader };