Hi,
I’m trying to render a 3D bounding box (selection gizmo / outline) entirely in a post-process material.
Currently I have access to the following data:
- Screen-space depth
- Screen-space normals
- Bounding box pivot (world position)
- Bounding box min/max (or extents)
I’d like to avoid rendering an additional mesh if possible.
So far I’ve considered two approaches:
- Compute the 8 bounding box corners on the CPU, project them to screen space, pass them to the shader, and reconstruct the 12 edges in screen space.
- Perform a ray-box intersection (ray vs. AABB/OBB) per pixel in the post-process shader.
However, neither approach feels ideal:
- The first requires updating and sending all 8 projected vertices every frame.
- The second requires per-pixel ray calculations, which may become expensive.
Is there a more common or efficient technique used for this problem?
I’m especially interested in how modern game engines (Unreal Engine, Unity, etc.) implement editor selection bounding boxes or placement gizmos in screen space.
Any papers, articles, or engine source references would also be greatly appreciated.