UnpackDepthRGBAShader.js 747 B

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