UnpackDepthRGBAShader.js 1018 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. console.warn( "THREE.UnpackDepthRGBAShader: As part of the transition to ES6 Modules, the files in 'examples/js' were deprecated in May 2020 (r117) and will be deleted in December 2020 (r124). You can find more information about developing using ES6 Modules in https://threejs.org/docs/#manual/en/introduction/Installation." );
  2. /**
  3. * Unpack RGBA depth shader
  4. * - show RGBA encoded depth as monochrome color
  5. */
  6. THREE.UnpackDepthRGBAShader = {
  7. uniforms: {
  8. "tDiffuse": { value: null },
  9. "opacity": { value: 1.0 }
  10. },
  11. vertexShader: [
  12. "varying vec2 vUv;",
  13. "void main() {",
  14. " vUv = uv;",
  15. " gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
  16. "}"
  17. ].join( "\n" ),
  18. fragmentShader: [
  19. "uniform float opacity;",
  20. "uniform sampler2D tDiffuse;",
  21. "varying vec2 vUv;",
  22. "#include <packing>",
  23. "void main() {",
  24. " float depth = 1.0 - unpackRGBAToDepth( texture2D( tDiffuse, vUv ) );",
  25. " gl_FragColor = vec4( vec3( depth ), opacity );",
  26. "}"
  27. ].join( "\n" )
  28. };