View Full Version : oblique near plane in projection matrix

Tom Tong

06-20-2013, 03:20 AM

Dear Sir/Madam

Hello.

How could I adjust the projection matrix to project NDC point to the oblique near plane?

https://docs.google.com/uc?export=download&id=0B9-c1U-9JpxjbWo5UF9Sb25YbTg

I try hard to search in the internet. But I still could not find the answer. Please help.

Tom Tong

Dark Photon

06-20-2013, 09:18 PM

How could I adjust the projection matrix to project NDC point to the oblique near plane?

Well, you're starting with what appears to be an on-axis frustum, and you're going to flip to an off-axis frustum. So you'll be calling glFrustum (or something like it) to explicitly specify L,R,B,T,N,F.

Ok, the point at which your L/R/B/T planes meet (if you extend them) is the eyepoint. The eyepoint doesn't change in your picture as you want the same LRBT sides.

Given a near plane, draw a vector from the eyepoint normal to the near plane (as you have done). That vector is your eye-space -Z axis, and the distance is your near distance

Your far plane is parallel to the near plane, so chose similarly.

With your eyepoint/near/far planes oriented in EYE-SPACE (such that eyepoint is (0,0,0), near plane is Z=-near, far plane = Z=-far, +X=right, and +Y= up), The Left and Right glFrustum values are identified by the coordinates on the near plane at which you hit the left and right planes, respectively. Similarly for Top and Bottom.

Tom Tong

06-24-2013, 04:06 AM

Thank you for your reply.

I would like to do some thing like 3D pavement art on the computer screen.

The image will be shown in correct way only if I view the screen from specific angle.

What should I adjust on the projection matrix?

Tom Tong

GClements

06-24-2013, 11:12 AM

I would like to do some thing like 3D pavement art on the computer screen.

The image will be shown in correct way only if I view the screen from specific angle.

You should set up the texture matrix as if for a camera located at the correct viewpoint, then use the vertex coordinates as texture coordinates. E.g.

glMatrixMode(GL_TEXTURE);

glLoadIdentity();

glScalef(0.5, 0.5, 1);

glTranslatef(1, 1, 0);

gluPerspective(...);

gluLookAt(...);

glMatrixMode(GL_MODELVIEW);

glBegin(...);

glTexCoord3f(x0,y0,z0);

glVertex3f(x0,y0,z0);

glTexCoord3f(x1,y1,z1);

glVertex3f(x1,y1,z1);

...

glEnd();

The behaviour of texture matrix is effectively the inverse of the projection and model-view matrices, so when the combination of model-view and texture matrices match the texture matrix, the two cancel out.

The glTranslate() and glScale() calls correct for the fact that normalised coordinates are -1 to +1 whereas texture coordinates are 0 to 1.

Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.