Skip to content

Instantly share code, notes, and snippets.

@paniq
Last active October 23, 2025 15:19
Show Gist options
  • Select an option

  • Save paniq/6c7a465b841dc2c87294c61108370389 to your computer and use it in GitHub Desktop.

Select an option

Save paniq/6c7a465b841dc2c87294c61108370389 to your computer and use it in GitHub Desktop.
Ellipsoid Frustum Intersection

Yesterday I posted a problem to math stack exchange that bothers me for a while now, and right after I've had a few exchanges on Twitter that inspired me to attempt a solution.

Basically, the problem is about a form of refined raytracing where we render a big list of convex 3D brushes (and I decided to start with Ellipsoids, since they're so useful) to the screen, without any precalculated accelleration structure. How does it work? Basically, if we had a way to figure out for a portion of the frustum whether it contained a brush, we could

  1. Start with a very low resolution
  2. Collect a list of ellipsoids contained in each tile, culling the ones we don't need
  3. Then subdivide each tile into four smaller tiles and repeat
  4. Until we hit per-pixel resolution, then we are done.

And this brings us to the problem: we want to solve for a tile on screen

  1. Whether an ellipsoid arbitrarily parametrized in world space is overlapping this tile
  2. What the near and far depth range of the overlapping portion is (important for culling, but also ray-space CSG)
  3. Whether the ellipsoid covers the tile fully (occludes its background completely, also important for culling)
  4. At which depth range the occlusion is 100% (so we can also cull overlapping ellipsoids)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment