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: Problem with the View Volume?

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

    Problem with the View Volume?

    Good day everyone,

    I am having a problem and I was hoping someone could help me. I am on Windows Vista, running OpenGL 3.3, and GLSL 3.3.

    I am able to draw lots of different objects, and do things with them in the vertex and fragment shaders.

    However, there is still one problem I have that I can not figure out.

    Here is the situation:

    - I create a window.
    - I create vertex and fragment shaders that are basically just pass throughs.
    - I then draw a simple square.
    - If I translate the square in the Z direction by 0.5, -0.5, 1.0, or -1.0, the square will still appear in the window.
    - I can translate the square up and down, left and right, and it works as intended.
    - However, if I translate the square by anything more than 1.0 or -1.0 in the Z direction, I no longer see the square.

    It seems as if by default, the viewing volume is a 2x2 cube centered on the origin, and only vertex's falling within this volume will be mapped to the window.

    So if there is a vertex that is more then 1.0 units from the origin in the Z-direction, then it gets clipped.

    Is this a correct interpretation of the problem?

    Also, how do I solve this problem?

    Warmest regards,

    Shawn

  2. #2
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    It's not a problem; it's just clip space.

    Assuming your vertex shader is not doing any perspective projection, your gl_Position W coordinates will be 1.0. So you're effectively using an orthographic projects. So the object isn't supposed to appear to move based on the Z.

    However, once you exceed the boundaries of clip-space (which is +/- W in all three axes. And since W is 1.0...), the triangle won't be rendered. None of the triangle is within the clip-space volume, and thus none of it will be visible.

    How you "solve the problem" depends entirely on what you want to have happen. Which you have not explained.

  3. #3
    Newbie Newbie
    Join Date
    Feb 2013
    Posts
    2
    Quote Originally Posted by Alfonse Reinheart View Post
    It's not a problem; it's just clip space.

    Assuming your vertex shader is not doing any perspective projection, your gl_Position W coordinates will be 1.0. So you're effectively using an orthographic projects. So the object isn't supposed to appear to move based on the Z.

    However, once you exceed the boundaries of clip-space (which is +/- W in all three axes. And since W is 1.0...), the triangle won't be rendered. None of the triangle is within the clip-space volume, and thus none of it will be visible.

    How you "solve the problem" depends entirely on what you want to have happen. Which you have not explained.
    How do I change the clip-space volume?

    For example, if I translate a square to z = -10, I dont want it to disappear.

  4. #4
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    You don't change clip space. You create a transformation from your world space to clip space.

    If you want your Z extent in your world space to be +/- 100, then you'll need to multiply all of your Z coordinates by 1/100 before storing them in gl_Position.

Posting Permissions

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