Intersection.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "// Main intersection function for Voxel scenes.\n\
  3. // See IntersectBox.glsl, IntersectCylinder.glsl, or IntersectEllipsoid.glsl\n\
  4. // for the definition of intersectShape. The appropriate function is selected\n\
  5. // based on the VoxelPrimitive shape type, and added to the shader in\n\
  6. // Scene/VoxelRenderResources.js.\n\
  7. // See also IntersectClippingPlane.glsl and IntersectDepth.glsl.\n\
  8. // See IntersectionUtils.glsl for the definitions of Ray, NO_HIT,\n\
  9. // getFirstIntersection, initializeIntersections, nextIntersection.\n\
  10. \n\
  11. /* Intersection defines (set in Scene/VoxelRenderResources.js)\n\
  12. #define INTERSECTION_COUNT ###\n\
  13. */\n\
  14. \n\
  15. RayShapeIntersection intersectScene(in vec2 screenCoord, in Ray ray, out Intersections ix) {\n\
  16. // Do a ray-shape intersection to find the exact starting and ending points.\n\
  17. intersectShape(ray, ix);\n\
  18. \n\
  19. // Exit early if the positive shape was completely missed or behind the ray.\n\
  20. RayShapeIntersection intersection = getFirstIntersection(ix);\n\
  21. if (intersection.entry.w == NO_HIT) {\n\
  22. // Positive shape was completely missed - so exit early.\n\
  23. return intersection;\n\
  24. }\n\
  25. \n\
  26. // Clipping planes\n\
  27. #if defined(CLIPPING_PLANES)\n\
  28. intersectClippingPlanes(ray, ix);\n\
  29. #endif\n\
  30. \n\
  31. // Depth\n\
  32. #if defined(DEPTH_TEST)\n\
  33. intersectDepth(screenCoord, ray, ix);\n\
  34. #endif\n\
  35. \n\
  36. // Find the first intersection that's in front of the ray\n\
  37. #if (INTERSECTION_COUNT > 1)\n\
  38. initializeIntersections(ix);\n\
  39. for (int i = 0; i < INTERSECTION_COUNT; ++i) {\n\
  40. intersection = nextIntersection(ix);\n\
  41. if (intersection.exit.w > 0.0) {\n\
  42. // Set start to 0.0 when ray is inside the shape.\n\
  43. intersection.entry.w = max(intersection.entry.w, 0.0);\n\
  44. break;\n\
  45. }\n\
  46. }\n\
  47. #else\n\
  48. // Set start to 0.0 when ray is inside the shape.\n\
  49. intersection.entry.w = max(intersection.entry.w, 0.0);\n\
  50. #endif\n\
  51. \n\
  52. return intersection;\n\
  53. }\n\
  54. ";