I have a gray scale texture which is being applied to an object. When the gray scale texture is rendered, I want it to also render into the depth buffer. I wrote the following fragment program to accomplish this:
!!ARBfp1.0 TEMP tex0; TEX tex0, fragment.texcoord, texture, 2D; MOV result.depth, tex0.r; MOV result.color, tex0; END
I tried this but it seems like any color that isn’t 100% white is being written to the very front of the zbuffer.
I’m assuming that the values written to result.depth are not linearly mapped into the actual zbuffer. Does anybody know how to tranform the texture color so that it fits linearly into the zbuffer?
I’ve set the depth range from 0 to 1. I’ve also set the near and far clip planes to 0.1 and 100.
Thanks in advance,