portal-oblique-frustum-clipping
Installation
SKILL.md
Portal Camera Transform and Oblique Frustum Clipping
What this builds
The two pieces of math that make a portal correct rather than merely plausible:
- The portal camera transform. Given the viewer's camera, portal A (the opening) and portal B (the destination), place a second camera so that what it sees through B is exactly what the viewer should see through A.
- The oblique near plane. Modify that camera's projection matrix so its near clipping plane lies exactly on portal B's plane, so geometry between the portal camera and the destination portal is never drawn.
Without the first, the view slides incorrectly as the viewer moves and reads as a video panel. Without the second, objects standing behind the destination portal appear floating in the opening, which is the single most recognisable portal bug.