skynet

08-20-2003, 12:54 PM

Hello!

I´m currently trying out projective textures. The main thing, projecting the texture itself worked out to be easy. But I (inspite of most papers/tutorials) I also want to use the (projected) z-coordinate for another texture, in this case in order to achieve falloff-effects. The falloff should be done by looking up the distance in a 1D-texture. For this to work I need a _linear_ mapping from [nearz,farz] to [0,1]. First I tried a standard projection matrix. After some hours of trying I finally convinced myself that the x,y projection is done ok (as expected), but the falloff is MUCH too much. So I placed some test z-values into the matrix. The projected z-values are not equally distributed from 0..1. Which is AFAIK a desired effect for the depthvalues in the depthbuffer.

So my question is: is there a projection matrix that projects x and y perspectivly as usual, but maps z linearly from nearz..farz to 0..1 ?

I know, this post is probably off-topic, sorry for that. But I think here are the most competent users able to answer this question.

I´m currently trying out projective textures. The main thing, projecting the texture itself worked out to be easy. But I (inspite of most papers/tutorials) I also want to use the (projected) z-coordinate for another texture, in this case in order to achieve falloff-effects. The falloff should be done by looking up the distance in a 1D-texture. For this to work I need a _linear_ mapping from [nearz,farz] to [0,1]. First I tried a standard projection matrix. After some hours of trying I finally convinced myself that the x,y projection is done ok (as expected), but the falloff is MUCH too much. So I placed some test z-values into the matrix. The projected z-values are not equally distributed from 0..1. Which is AFAIK a desired effect for the depthvalues in the depthbuffer.

So my question is: is there a projection matrix that projects x and y perspectivly as usual, but maps z linearly from nearz..farz to 0..1 ?

I know, this post is probably off-topic, sorry for that. But I think here are the most competent users able to answer this question.