Funny Depth Value Behaviour

Started by
12 comments, last by GameDev.net 19 years, 6 months ago
When you say the depth doesn't change you mean that value?
"fDepth = mul( matMV, IN.pos ).z"

Sorry,I can't help you with that. I can't see any reason not to change, if you're binding the matrices correctly. I mean, the modelview matrix changes when the camera moves, so there is no reason for fDepth to be the same.

Anyway,just to be sure: You're not using the projection matrix for camera movement and rotation, right? That stuff goes into the modelview matrix.
Advertisement
hi mike, what range will the depth value be in when its passed
to the fragment shader?

ie. will it be:
near clip plane < depth < far clip plane

or will it be [-1, 1] ?

cheers
Danu
"I am a donut! Ask not how many tris/batch, but rather how many batches/frame!" -- Matthias Wloka & Richard Huddy, (GDC, DirectX 9 Performance)

http://www.silvermace.com/ -- My personal website
Look, this could go on forever. Even if I give you the answer, you'll just put it in the code without understanding it. It won't do you any good. Just read the red book about different coordinate systems(object,eye,window coordinates) and you will figure it out yourself easily. I hate to quote myself but:

Quote:
It all depends on the coordinate system you decide to use. You say you need to compare the fragment's z value to a focal plane,which I assume you supply. If you express the focal plane in eye coordinates, you'll need the fragments pos in eye coordinates. If you express it in window coords, you'll need the fragment's window zvalue, and so on.


If you understood the GL fundumentals(which you absolutely must do), you would understood that and solve your own problem

Learn the basics well, and only after that start messing with more advanced features like shaders.

[Edited by - mikeman on October 7, 2004 3:21:36 PM]
i understand your frustration mike, imagine mine :)

i have done everything i could, im putting it down as some kind
of driver bug.

the interpolation is NOT working, seriously, you can't even
imagine.

the reason i was asking you the co-ord systems stuff was
because this shader problem made me second guess my knowledge.

you wont beleive this code dosnt work:
float4 p = mul( matMV, IN.position );
OUT.fDepth = sqrt( dot(p,p) );

that code obviously gives the distance between the cam (0,0,0) and teh vertex.

yet that dosn't even interpolate into the fragment shader, it simply remains _CONSTANT_ its driving me crazy.

This topic is closed to new replies.

Advertisement