You guys have pulled through so far. Here’s your final test.
I’m rendering a bunch of points in 3D. Rotating them around, scaling them up and down. This is OpenGL ES 1.1 on the iPhone in case you didn’t catch that. But as I scale up, my points start to disappear. I think that this has to do with clipping planes. But for the life of me I can’t figure out wtf to do with them. From the OpenGL ES 1.1 spec:
Primitives are clipped to the clip volume. In clip coordinates, the view volume is
deï¬ned by
−wc ≤ xc ≤ wc
−wc ≤ yc ≤ wc
−wc ≤ zc ≤ wc
Can someone show me the way to the wc? This reference goes on to talk about clip planes:
This view volume may be further restricted by as many as n client-deï¬ned clip
planes to generate the clip volume.
But I don’t want to further restrict it, I want to open it up. I’ve wasted away many hours of my life that I’ll never get back messing around with glDepthRangef and glFrustumf, but I’m just out of my depth and getting frustrated. (see what I did there?) I don’t even know whether those methods do anything that will help me. All I want to do is make it so when things go further away, I still see them. Not infinitely, but I just want to know how to have control over it. kthxbai.
Post some code. I think you need to take a closer look at glFrustumf. The last 2 parameters are key (zNear, zFar). Make sure zNear is set to something like 0.1. Define zFar far 😀 say around 1000.
From a brief meditation with my guru (named Google) I was able to fing the following which will hopefully help you:
1. OpenGL specifies a default view volume that is a cube with sides of length 2 centered at the origin. i.e. wc == 2 in your example
2. glOrtho(left, right, bottom, top, near, far) // specifies the view volume as:
left < x < right
bottom < y < top
near < z < far
I hope this helps. 🙂
before, you’d had to go to a forum/mailing list to post your problem and wait.
what popularity changes: now people come directly to you when you need help.
nice, isn’t it…
What’s the range from your viewpoint to the most distant points you are drawing? The z-buffer is very sensitive to numerical precision, with most of the precision distributed closer to the near clipping plane. Try pushing out your near clipping plane as far as possible
spacehunter, yeah, i messed around with near and far without much success, including those values you mentioned.
marc, that helps a bit, but I’m not using ortho.
pedro. i don’t think my far points would be any more than 10 or 20.
actually, i just put ortho back in there and it solves the problem and looks good. my understanding is that ortho gives you a non-perspective projection, which I thought would not look good in my app, but it seems just fine.
Are you sure these are not points being projected behind the near plane ? The depth buffer techniques in the iPhone PowerVR chip are a bit odd, compared to other platforms.
As for the wc … it’s clipping in homogenous view space, hence the w.
To clarify, my point about the near plane and my point about the powervr depthbuffering technology weren’t ment to be directly related.
A quick pipeline overview:
When us mortals send points to be drawn in the buffer they undergo a series of geometric transformations. In order:
[Object Space] -> [World Space] -> [Camera Space] -> [Normalized Device Space] -> [Screen Space]
Normally Object Space is the World Space so ignore it.
All transformation like Scale,Rotation,Translation occurs in WorldSpace, so every time you call somehitng like glRotate() you are modifying the ModelMatrix.
After that in order to put everything “in front of” the camera you transform the rotated,scalated,translated point by the ViewMatrix. The ViewMatrix is defined when we call gluLookAt().
In order to optimize things OpenGL defines both matrix as one “MODELVIEW” matrix.
The “wc” test occurs between Camera Space and Normalized Space.
The point in Camera Space is multiplied by the Projection Matrix and it’s coordinates will have some “x,y,z,w”..
Because of some mathematical properties of the projection transform the “w” coordinate contains the boundary of visibility of the “x,y,z”. In this case your “w” is the “wc”.
To get to this step. You’ll need to get the ModelViewMatrix and multiply it by your point. After that you need the ProjectionMatrix and again multiply your point. After that probably your point will be ready to be clipped following the test:
−wc ≤ xc ≤ wc
−wc ≤ yc ≤ wc
−wc ≤ zc ≤ wc
I think it’s that the way!