Reverse projection problem.

Hi

I have implemented my first shadow effect using projective texture mapping. I wondered how to eliminate the reverse projection. Now i’m using clip planes to draw only the positive geometry, but i think this is not a good idea because sometime the clip plane doesn’t gave the correct result. The NVIDIA paper says that it can be solved using 1D texture map, but how does it work?

Thank’u!

                                     Johnson.

Use texture coordinate generation to project the light direction onto texture S coordinate.

Turn on GL_CLAMP_TO_EDGE for that coordinate. Make the first and the last pixel of the texture black, and the others white.

Set up the texture coordinate generation scale/offset such that the parts you want get mapped to white, and the parts you don’t, black.

Turn on MODULATE multitexturing.

hi,

do you have any sample code illustrating how to use this 1D texture map on q coodinate ?
or do you know where I cna find any ?

thanks

If you are using ARB_fragment_program capable hardware, I would suggest that you simply look
at the w component of your texture coordinate
and handle the w<0 case there.

Here is a Cg snippet I use for that:

float  shadow   = ( vert.projCoords.w < 0 ) ? 0 : tex2Dproj( shadowMap, vert.projCoords ).r;

I also do that for the projected spotlight texture.

There are a lot of other methods though. Besides the 1D texture one, you can even use a clip plane to clip everything behind the light (assuming you’re using a spotlight). I also seem to remember something about calculating a vertex spotlight and multiplying that result with your per pixel lighting w/ shadow map result. I’ve never tried that though. I just use my Cg shader method from above. :wink:

-SirKnight

hi,

thanks for your informations about the CG method.
But unfortunatly, I can not use any fragment shader on my hardware, so I really need to know more about the 1D texture map method.
Tell me everything you have concerning this method.

thanks

Ron Frazier showed how reverse projection can be fixed using cubemapping in following article:

http://www.ronfrazier.net/apparition/index.asp?appmain=research/per_pixel_lighting.html

I just successfully implemented it for regular texture projection using texgen and it works ! :slight_smile:
Also might add, for this you wont need any pixel shader stuff or nv register combiners

I attempted to implement the ARB_fragment_program solution that was mentioned above. I haven’t yet been able to work with the case where q < 0, because the fragment program without such a condition seems to prevent the projected texture from being displayed.

Here is the fragment program:

!!ARBfp1.0
ATTRIB tex = fragment.texcoord;
ATTRIB col = fragment.color.primary;

if q is negative, kill fragment

KIL tex.q

OUTPUT outColor = result.color;
TEMP tmp;
TXP tmp, tex, texture, 2D;
MUL outColor, tmp, col;
END

Is the TXP line not suitable when rendering with a projected texture?