Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: oblique near plane in projection matrix

  1. #1
    Newbie Newbie
    Join Date
    Jun 2013
    Posts
    2

    oblique near plane in projection matrix

    Dear Sir/Madam

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



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

    Tom Tong

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,225
    Quote Originally Posted by Tom Tong View Post
    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.

  3. #3
    Newbie Newbie
    Join Date
    Jun 2013
    Posts
    2
    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

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,589
    Quote Originally Posted by Tom Tong View Post
    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.
    Code :
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •