How to draw a frustrum from a given position


i’m doing projective texture mapping. I want to visualise the projection that I’m using - i.e draw say a pyramid with the top at the light position and the rest aligned with the projection (frustrum) i’m using.

I would like to use the terms given to glFrustrum = i.e a top, bottom, left right, near and far.

I know glFrustrum calculates a matrix in eye space, and I would initially create my pyramid according to these coordinates. How can I take this pyramid and transform it to the light position?

I have a modelview matrix for the light, which allows me to render from that position. I’m not sure how to go from this to a transform that I can actually apply to my “pyramid” though.

Thanks for any help>!

EDIT: I know how to do construct this using vectors (i have a light direction) but would like to know how to do this by transforming a given set of vertices in eye space. cheers!

There is a demo at

“Simple Soft Shadows”

which draws the frustum as a pyramid.

Hmm I don’t see it…(the frustrum)

  • There are a couple of other shadow mapping examples there, it may be one of those (Hardware Shadow Mapping looks promising)

Assuming you have the direction from light to the scene, lets call it lz and the camera vertical direction (from light point of view) is world Y.

You can compute basis vectors in light space: (lx,ly,lz) expressed in world space like this:

lx = normalize(cross(Y,lz)); // cross is cross product
ly = normalize(cross(lz,lx);
lz = lz

I am not sure about the vector order inside cross product, I let you verify this.

Then, you move along the lz axis until the near plane and move along lx and ly to left, right, up (the glFrustum arguments) and down to find the pyramide points coordinates (on the near plane).

Finally you can easily find the view volume points on the far plane which lengthens vectors from light to points on the near plane.

Hoping this is clear enough (sorry, I don’t have time to draw a figure). :slight_smile: