View Full Version : the TRUE z-value, how can I compute it out?
03-21-2001, 08:54 PM
It's said the z-value stored in OpenGl is between [0, 1] and it is converted by the following equation:
z' = (-(f+n)/(f-n))*z - (2fn/(f-n))*w.
That means, the TRUE z value is inverse of the equation:
z=-(f-n)/(f+n)*z' - 2fn/(f+n)*w,
where z' is between [0,1].
Is that right?
Also, can I assume w=1.0 always?
okay, now i see what you're getting at. but i'm not sure about the validity of your equation, there. but i'm guessing you realise it's the third row of the equation multiplied by the vector, DIVIDED by the fourth row of the equatiojn, multipled by the vector. does this make sense? recapping the w co-ordinate:
if P is our projection matrix, and v and v' is the vertex and its projection respectively, then
v' = P v
[ x' y' z' w'] ' = P [ x y z w ] '
(where ' on the vector is the transpose op and ' on the scalar indicates the projected coordinate).
now, to convert the homogeneous projected vector into a cartesian projected vector, then
z.cartesian = z' / w'
because we divide by w... so.... getting back to your equation: you multiply the third row of P by the vector (to get z') and divide it by the fourth row of P by the vector (to get w').
so, then, what's w? well, in this case, then yes---you CAN simply set w to equal 1.0.
hope this helps,
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.