-vPosition.z vs. length( -vPosition.xyz )

this is actually a very simple question… will Depth and Depth2 be the same? they seem to give the same results, but I prefer to make sure… thanks!

vs:

vPosition = gl_ModelViewMatrix*gl_Vertex;

fs:

float Depth = -vPosition.z;
float Depth2 = length( -vPosition.xyz );

will Depth and Depth2 be the same?

It rather depends on what the values for gl_Vertex and gl_ModelViewMatrix are. But in the general case, no.

Please correct me if I am wrong but they will be equal only when x and y equal 0;

let say that gl_Vertex( x,y,z)
and ur modelview matrix is the identity matrix .
so vPosition in eye space will be vPosition(x,y,z,1) in homogeneous form.

so vPosition.z=length( vPosition.xyz ) only if (x=y=0 ) .

yep, could be formulated as finding the values of x, y and z for which x^2 + y^2 + z^2 = z^2, or more simply the x and y for which x^2 = - y^2. None, really. :slight_smile:

complex problem…

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.