depth_frag.glsl 913 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #if DEPTH_FORMAT != 3100
  2. uniform float mNear;
  3. uniform float mFar;
  4. #endif
  5. #if DEPTH_PACKING == 3200
  6. uniform float opacity;
  7. #endif
  8. #if DEPTH_FORMAT != 3100
  9. varying float vViewZDepth;
  10. #endif
  11. #include <common>
  12. #include <packing>
  13. #include <logdepthbuf_pars_fragment>
  14. #include <clipping_planes_pars_fragment>
  15. void main() {
  16. #include <clipping_planes_fragment>
  17. #include <logdepthbuf_fragment>
  18. float transformedDepth = 0.0;
  19. #if DEPTH_FORMAT == 3100 // AutoDepthFormat
  20. transformedDepth = gl_FragCoord.z;
  21. #elif DEPTH_FORMAT == 3101
  22. transformedDepth = viewZToLinearClipZ( vViewZDepth, mNear, mFar );
  23. #elif DEPTH_FORMAT == 3102
  24. transformedDepth = viewZToInvClipZ( vViewZDepth, mNear, mFar );
  25. #endif
  26. #if DEPTH_PACKING == 3200
  27. gl_FragColor = vec4( vec3( transformedDepth ), opacity );
  28. #elif DEPTH_PACKING == 3201
  29. gl_FragColor = packLinearUnitToRGBA( transformedDepth );
  30. #endif
  31. }