0
votes

I'm working on a project where I want to take a collection of vertices that I have in NDC and put them back in world space, but I want them all to lie in a plane. Since there are an infinite number of vertices that can all be projected to the same NDC x and y, is it safe to say that the z-coordinate is completely independent? Can I alter the z-coordinate and "unproject" the point back through the inverse of all the matrices in the pipeline and have it appear in the same "place" on the screen? That's my understanding of how it is supposed to work, is that correct?

If it is, then my intuition is that if I wanted to put all the points in the same plane (in world space) as one specific point (with a normal conveniently equal to the cameras look direction), then all I should have to do is set their NDC z-value equal to the z-value of that particular NDC point? Is that correct? Does that make sense?

2

2 Answers

1
votes

Yes, points with the same z value will be in a plane whose normal is parallel to the view direction. Although the conversion from NDC z values to depth is some arbitrary function, it only depends on the z value (not the x and y).

0
votes

The Z value is not independent, it would still be the depth into the scene even in NDC's.

Meaning, many vertices may have the same X & Y, they may have different Z's and might not be on the same plane.

If you were to modify the Z component, from the right view it would look like it was on the same plane, but really its moving along a ray. Here is a paper that helps describe that ray. http://myweb.lmu.edu/dondi/share/cg/unproject-explained.pdf

If you want to go from NDC into world space and then be on the same plane, all you would need to do is project them all onto that plane once there in world space.

In case it may help, here is how to project points onto a plane:
How do I find the orthogonal projection of a point onto a plane

Just as a reminder here is a refresher on how to get into NDC:
http://www.songho.ca/opengl/gl_transform.html