PDA

View Full Version : Reverse projection problem.



Johnson.N.M.B
10-31-2004, 05:38 PM
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.

jwatte
10-31-2004, 06:09 PM
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.

equentric
11-24-2004, 12:05 AM
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

cass
11-24-2004, 11:06 AM
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.

SirKnight
11-24-2004, 01:44 PM
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. ;)

-SirKnight

equentric
11-25-2004, 01:01 AM
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

CrazyButcher
11-27-2004, 05:17 AM
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 ! :)
Also might add, for this you wont need any pixel shader stuff or nv register combiners

list67
12-27-2006, 05:03 PM
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?