Skip to content

Instantly share code, notes, and snippets.

@Lucodivo
Lucodivo / ObliqueProjectionMatrix.cpp
Created July 31, 2021 23:23
Oblique Projection Matrix for Portals
/*
* // NOTE: Oblique View Frustum Depth Projection and Clipping by Eric Lengyel (Terathon Software)
* Arguments:
* mat4 perspectiveMat: Perspective matrix that is being used for the rest of the scene
* vec3 planeNormal_viewSpace: Plane normal in view space. MUST be normalized. This is a normal that points INTO the frustum, NOT one that is generally pointing towards the camera.
* vec3 planePos_viewSpace: Any position on the plane in view space.
*/
mat4 obliquePerspective(const mat4& perspectiveMat, vec3 planeNormal_viewSpace, vec3 planePos_viewSpace, f32 far) {
mat4 persp = perspectiveMat;