depth.chunk 444 B

1234567891011121314
  1. // Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
  2. #include <common/common-define>
  3. #include <common/math/coordinates>
  4. #pragma rate DepthTex pass
  5. uniform sampler2D DepthTex; //Sample_Point_Clamp
  6. float GetDepthFromTex(vec2 uv) {
  7. return texture(DepthTex, saturate(uv)).r;
  8. }
  9. float GetLinearDepthWithProj(vec2 uv, mat4 proj) {
  10. float depthHS = GetDepthFromTex(uv) * 2.0 - 1.0; // -1.0 ~ +1.0
  11. return -GetCameraDepthRH(depthHS, proj);
  12. }