UnpackDepthRGBAShader.js 748 B

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