This topic is now archived and is closed to further replies.


calculating view frustrum from view, proj matrices

Recommended Posts

ggoodwin37    122
I know this is a pretty basic question, but it''s been a while since linear algebra for me... If I know my View and Projection matrices, how can I calculate the 4 (disregarding near/far clip planes) plane equations describing the view frustrum? First I have to compose the two together, then I''m guessing that have to take pairs of vectors out of the composed matrix and use them to generate the plane normal via cross this correct? What details am I missing? How do you get those vectors out of the View/Proj composition? thanks

Share this post

Link to post
Share on other sites
mohamed adel    174
the equation of the projection matrix is

p=|cot(FOVw/2) 0 0 0|
|0 cot(FOVh/2) 0 0|
|0 0 f/(f-n) 0|
|0 0 0 -fn/(f-n)|

n: near plane distance
f: far plane distance
fovw: horizontal field of view in radians
fovh: vertical field of view in radians

so if you have the projection matrix then the element (3,3) equals f/(f-n) and the element (4,4) equals -f/(f-n) .then you can solve as two equations in two unknowns to find f and n.then the equation of the near plane in the camera coordinates is z=n, and the equation of the far plane in the camera coordinates is z=p.
the equation of the right plane is z-x/(tan FOVh)=0
the equation of the left plane is z+x/(tan FOVh)=0
all difined in the camera coordinates i.e the eye is the origin,the right vector is the positive x direction,the up vector is the positive y direction. you can use matrices to change them to other coordinate systems you want.

Share this post

Link to post
Share on other sites