Re: questions about the perspective projection matrix ???
- From: mast4as <mast4as@xxxxxxxxx>
- Date: Tue, 8 Jan 2008 08:20:00 -0800 (PST)
Thank you Dave so much. Everyone's else answer helped but yours was
really good ;-)
Start out with the assumption that the hardware *will* divide by W after
multiplying by the perspective matrix. Also, for the perspective to
work properly, the W component really needs to be a copy of camera Z (or
-Z, depending on your convensions). Also assume that the hardware
clipping in Z uses Z=0 and Z=1 planes. Given all these constraints,
the third row (or column, again depending on your conventions) of the
projection matrix must implement a function f(z) with the properties:
f(z) = 0 when z = nearPlane
f(z) = farPlane when z = farPlane
so that f(z)/z is in [0..1] for points between the near and far plane.
ok i get that but I want to confirm the math decomposition to be sure
and for future reference:
basically you can can remap z within the range [0, 1] by using the
simple remap function:
new value within [0, 1] range = (val - min_val) /(max_val - min_val)
applied to our situation that is:
depth = (z - near)/(far - near) (Eq 1)
although we want "depth" to be equal to "far" when z = farPlane
therefore we can multiply Eq 1 by far.
depth = (z - near)/(far - near) * far
but now depth is in the range [0, far] and to remap it back to [0, 1]
we need to divide Eq 2 by z.
depth = (z - near)/(far - near) * far / z (Eq 3)
Is that correct ?
That would be all good to me but another stupid question then ? Why
f(z) = farPlane when z = farPlane. Why just not deciding that f(z) = 1
when z = farPlane. That would simply remove the problem of far/z which
is making Eq 3 non linear ?
I understand that hardware implement all this but I am trying to
understand it conceptually to replicate the behavior in sofware.
3/ In fact question (2) could be reformulated that way: why do we use
this formula as it seems that if we only need to compare the depth of
samples along a particular light ray to check which one is in front of
the others, using the distance from the samples to the eye position
would be just as good !
depth = sqrt(Px*Px + Py*Py + Pz*Pz)
Could someone please explain me why we use equation 1 instead of the
distance for example as a way of checking of which sample is in front
of the others, among all the possible samples aligned on a same light
ray ? Wouldn't that work too ?
First, you would need rendering hardware that *did not divide by W* in
the Z component. This could be built, or you could do all the work in
software, but that's not what is conventionally done. The usual
hardware divides all components by W, so the answer to #2 is what is
required by that hardware.
well i undersand that. I found also on a webpage that if you use the
distance, two samples which are on the same plane (plane being
perpendicular) to the view direction may have different values and
that it's better to have a system that provide the same value for two
samples lying on the same plane. Is that a valid explanation ?
Also, if you actually did this, you might find that you need to store Z
in floating point to get enough precision in Z for near values. The
usual formula provides some of this automatically, which might allow you
to us a fixed-point Z buffer in situations where it would not be
adequate if you simply quantized Z directly.
Ah that's true for hardware right ? Which precision is typically used
on graphics card for the depth ? 8, 16, 32 bits ? I guess if you
develop the technique in software z could be a float anyway which
should be enough precision.
There's one thing that I truly conceptually don't understand in the
book which is that line:
"All rays (which have been transformed) passing through the view point
are now parallel to the z-axis because the centre of projection has
been moved to negative infinity along the z-axis. This can be seen by
putting Pz = 0 into the above equation (P' = Mproj * P) giving P'z = -
inf. Making those rays that hit the eye parallel, in screen space,
means that hidden surface calculation need only be carried out on
those points that haven the same P'x, P'y coordinates. etc"
All points that map to the same position on screen have the same (X,Y)
coordinates, but generally different Z coordinates. Thus, all of the
scene points that map to (say) (100, 100) on screen form a line in
clipping space, and all of these lines are parallel to the Z axis.
More or less by definition, this means that the eyepoint is at infinity
(or minus infinity, again depending on your conventions).
cool that makes sense but isn't that just a construction of the mind ?
Or can it be proved mathematically. What I understand is that the z-
coordinate of the projected point on the image plane is just replacing
what the correct value is supposed to be for the projected point which
is the focal distance. Because we don't have any use for the focal
distance with store the depth instead. Indeed you can see points on
the same pixel location has having identical x-y coordinates and depth
values that we can use to order them. But does that make this points
aligned on a line parallel to the z-axis ? Again I am trying to
understand it from a math point of view ;-)
Thanks again so much.
Hope this thread will be helpful in the future.
Dave
.
- Follow-Ups:
- Re: questions about the perspective projection matrix ???
- From: Dave Martindale
- Re: questions about the perspective projection matrix ???
- References:
- questions about the perspective projection matrix ???
- From: mast4as
- Re: questions about the perspective projection matrix ???
- From: Dave Martindale
- questions about the perspective projection matrix ???
- Prev by Date: Re: questions about the perspective projection matrix ???
- Next by Date: Luminance calculation
- Previous by thread: Re: questions about the perspective projection matrix ???
- Next by thread: Re: questions about the perspective projection matrix ???
- Index(es):
Relevant Pages
|
Loading