IntersectDepth.js 1.2 KB

12345678910111213141516171819202122232425
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "// See IntersectionUtils.glsl for the definitions of Ray, Intersections,\n\
  3. // setIntersectionPair, INF_HIT, NO_HIT\n\
  4. \n\
  5. /* intersectDepth defines (set in Scene/VoxelRenderResources.js)\n\
  6. #define DEPTH_INTERSECTION_INDEX ###\n\
  7. */\n\
  8. \n\
  9. uniform mat4 u_transformPositionViewToUv;\n\
  10. \n\
  11. void intersectDepth(in vec2 screenCoord, in Ray ray, inout Intersections ix) {\n\
  12. float logDepthOrDepth = czm_unpackDepth(texture(czm_globeDepthTexture, screenCoord));\n\
  13. if (logDepthOrDepth != 0.0) {\n\
  14. // Calculate how far the ray must travel before it hits the depth buffer.\n\
  15. vec4 eyeCoordinateDepth = czm_screenToEyeCoordinates(screenCoord, logDepthOrDepth);\n\
  16. eyeCoordinateDepth /= eyeCoordinateDepth.w;\n\
  17. vec3 depthPositionUv = vec3(u_transformPositionViewToUv * eyeCoordinateDepth);\n\
  18. float t = dot(depthPositionUv - ray.pos, ray.dir);\n\
  19. setIntersectionPair(ix, DEPTH_INTERSECTION_INDEX, vec2(t, +INF_HIT));\n\
  20. } else {\n\
  21. // There's no depth at this location.\n\
  22. setIntersectionPair(ix, DEPTH_INTERSECTION_INDEX, vec2(NO_HIT));\n\
  23. }\n\
  24. }\n\
  25. ";