Whether a world-space point lies inside a closed mesh — the test the refraction split
uses to tell that the camera is inside a refracting shell.
Bounding-sphere and box rejection first (the common case: the camera is outside every
glass), then RAY PARITY against the drawn triangles: a ray from the point crosses
a closed surface an odd number of times when the point is inside. This works for
non-convex shells too — unlike a bounding-volume test, which would call a
camera inside the bounding sphere of a lens or a torus "inside" while it can still see
the front faces. The ray direction is deliberately irrational so it does not graze a
shared edge or vertex of an axis-aligned or icosahedral mesh, where a hit could be
counted twice. Only closed surfaces are eligible: every edge of the drawn triangles
must have two incident faces, with seam vertices welded by rounded position.
Closedness is cached by geometry attribute versions and draw range; parity is cached
per mesh, camera position and world matrix. Above 20,000 triangles the glass stays
double-sided rather than doing a large topology scan in a render frame.
Whether a world-space point lies inside a closed mesh — the test the refraction split uses to tell that the camera is inside a refracting shell.
Bounding-sphere and box rejection first (the common case: the camera is outside every glass), then RAY PARITY against the drawn triangles: a ray from the point crosses a closed surface an odd number of times when the point is inside. This works for non-convex shells too — unlike a bounding-volume test, which would call a camera inside the bounding sphere of a lens or a torus "inside" while it can still see the front faces. The ray direction is deliberately irrational so it does not graze a shared edge or vertex of an axis-aligned or icosahedral mesh, where a hit could be counted twice. Only closed surfaces are eligible: every edge of the drawn triangles must have two incident faces, with seam vertices welded by rounded position. Closedness is cached by geometry attribute versions and draw range; parity is cached per mesh, camera position and world matrix. Above 20,000 triangles the glass stays double-sided rather than doing a large topology scan in a render frame.