UnpackDepthRGBAShader.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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/index.html#manual/en/introduction/Import-via-modules." );
  2. /**
  3. * @author alteredq / http://alteredqualia.com/
  4. *
  5. * Unpack RGBA depth shader
  6. * - show RGBA encoded depth as monochrome color
  7. */
  8. THREE.UnpackDepthRGBAShader = {
  9. uniforms: {
  10. "tDiffuse": { value: null },
  11. "opacity": { value: 1.0 }
  12. },
  13. vertexShader: [
  14. "varying vec2 vUv;",
  15. "void main() {",
  16. " vUv = uv;",
  17. " gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
  18. "}"
  19. ].join( "\n" ),
  20. fragmentShader: [
  21. "uniform float opacity;",
  22. "uniform sampler2D tDiffuse;",
  23. "varying vec2 vUv;",
  24. "#include <packing>",
  25. "void main() {",
  26. " float depth = 1.0 - unpackRGBAToDepth( texture2D( tDiffuse, vUv ) );",
  27. " gl_FragColor = vec4( vec3( depth ), opacity );",
  28. "}"
  29. ].join( "\n" )
  30. };