• Advertisement
Sign in to follow this  

what is the range of clipping space in OpenGL?

This topic is 1873 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm a beginner in opengl, and I enounter a problem concering about clipping space.
I calculated perspective matrix myself and passed it to vertex shader, but why triangle was visible only when the z value of vertices multiplied by my perspective matrix is positive? Since the z value range of perspective frustum [n, f] is mapped to [-1. 1] in clipping space, any -1 < z < 1 should not be clipped which is just not the case in my situation. In case that my perspective matrix is miscalculated, I directly passed vertices with -1 < z < 0 to vertex shader, still I got nothing. but it works just fine with 0 < z < 1.

Share this post


Link to post
Share on other sites
Advertisement
From what I understand, near and far represent values that relate to camera space, not clip space.

If you use something like 0 and 100 for n and f respectively, you should be able to see geometry where incoming vertex z is negative.

Can you post the function that calculates the projection matrix, and your vertex shader?

Share this post


Link to post
Share on other sites
[quote name='Goran Milovanovic' timestamp='1354479288' post='5006366']
From what I understand, near and far represent values that relate to camera space, not clip space.

If you use something like 0 and 100 for n and f respectively, you should be able to see geometry where incoming vertex z is negative.
[/quote]
The near-plane value should never be zero, or you will lose an immense amount of precision (remember the depth buffer uses a logarithmic scale). The best values depend on the scale of the scene, but if you're working in meters, 0.1 to 1000 is a good start IMHO. Edited by Bacterius

Share this post


Link to post
Share on other sites
[quote name='Bacterius' timestamp='1354486513' post='5006407']
The near-plane value should never be zero, or you will lose an immense amount of precision (remember the depth buffer uses a logarithmic scale). The best values depend on the scale of the scene, but if you're working in meters, 0.1 to 1000 is a good start IMHO.
[/quote]

Ah, yes, as written here: http://www.opengl.org/archives/resources/faq/technical/depthbuffer.htm

Thanks for pointing that out.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement