Skip to main content
GameDev.net gamedev.net
🔒 Locked

Projective texturing remove back-projection

Started by glmisscelan Mar 5, 2008 at 11:06 AM 10 replies 3.6k views
Original Post
glmisscelan
glmisscelan
hi, is there any way to remove back-projection using fixed-pipeline and without clipping planes? I have heard something about using 1d texture but i cant find a clear explanation. Thanks in advance.
dpadam450
dpadam450
I think you can just say " if (Z coordinate in the lights frame < 0) then it is behind the projector, so don't do the extra 2d texture lookup.
NBA2K, Madden, Maneater, Killing Floor, Sims 
dpadam450
dpadam450
Nvm, I don't know how it would work in fixed-function.
NBA2K, Madden, Maneater, Killing Floor, Sims 
Vilem Otte
Vilem Otte
Or there is possible to create projective texture volume - (it looks like pyramid) in direction of projected texture and draw texture just in that volume (use stencil tests).
glmisscelan
glmisscelan
Thanks for your answers.

Here are some links with info


http://www.cg.tuwien.ac.at/courses/Realtime/slides/06shading_rtr2007.pdf

"Fold the back-projection factor into a 3D attenuation"

http://www1.cs.columbia.edu/~ravir/6160/papers/shadow_mapping.pdf

"Another problem that comes up with any projective texture mapping is the phantom
“negative projection”. This is actually pretty simple to remove at the cost of an
additional texture unit, or per-vertex color. The goal is just to make sure that the shadow
test always returns “shadowed” for surfaces behind the light."

Projective Texture Mapping - Nvidia Developers

"The sign of q becomes negative behind the projector, which inverts the texture image
in the reverse projection. Typically applications use a 1D texture or other interpolated
quantity to eliminate color contribution when the q coordinate of the projective texture
becomes negative."

http://ati.de/products/imageon238x/IMAGEON_238X_Rooms_Demo_Whitepaper.pdf

"Traditionally, the back projection is resolved by using a 1D texture with a black texture
border and OBJECT_LINEAR texture coordinate generation to fetch a value of black
behind the light plane and white in front of it."

http://216.239.59.104/search?q=cache:57RgGeIZIYgJ:www.cse.unsw.edu.au/~cs9018/lectnotes/ps/pt7.ps.gz+projective+texturing+1d+GL_OBJECT_LINEAR&hl=es&ct=clnk&cd=2≷=es&client=firefox-a"

"Use a 1D texture that lives in the q plane and
then modulate projective texture by 1D texture."


Every paper talks about a easy way using 1d texture i can understand what they want but i dont know how to code it.

Any help?
glmisscelan
glmisscelan
I found another text that explain it better,

http://www.cbloom.com/3d/techdocs/shadowmap_advanced.txt

"The traditional solution to the "back projection" problem is to use a "clipper" texture (the same way NVidia implements use clip planes in D3D). The clipper texture is a 1x2 texture with one black pixel and one white; you implement texture coordinate generation to create a "u" index into the texture such that the z coordinate of the shadow-generating camera gets mapped to u, with u = 0.5 at the shadow map plane. You then add the texel from the clipper to the shadow map before applying it to the scene (with saturation)."

How can i make this "implement texture coordinate generation to create a "u" index into the texture such that the z coordinate of the shadow-generating camera gets mapped to u"?

Thanks in advanced



dpadam450
dpadam450
I was nice enough to pick up my GL book. To do it fixed function, you have to draw the scene twice. It doesn't really say exactly how, but it clearly states that fixed function sucks for it and wont be supported probably (in the near future). Seriously though, people not using shaders.......I don't understand it. Shaders are available on any card that you are going to make a game for.
NBA2K, Madden, Maneater, Killing Floor, Sims 
glmisscelan
glmisscelan
Ok, you win.

I have it working on fixed pipeline (with back projection) i want to remove back projection on glsl but im getting problems, my shadow doesnt scale and translate correctly.

This is a pic on fixed

description of your image


this is with glsl

description of your image


thats the way i set texture matrix,
    glActiveTextureARB( GL_TEXTURE2_ARB);    glEnable(GL_TEXTURE_2D);    glMatrixMode( GL_TEXTURE);    glLoadIdentity();    glTranslatef(0.5, 0.5, 0);    glScalef(0.5, 0.5, 1);    gluPerspective(10.0f, (float)conf_get_scr(SCR_WD)/ (float)conf_get_scr(SCR_HG), 0.01, 100.0f);    gluLookAt(-36.80, -10.08, -0.81,              mos->mosinstance[instance].posicion.x,              mos->mosinstance[instance].posicion.y,              mos->mosinstance[instance].posicion.z,              0.0, 1.0, 0.0);    // Set up TexGen    glEnable(GL_TEXTURE_GEN_S);    glEnable(GL_TEXTURE_GEN_T);    glEnable(GL_TEXTURE_GEN_R);    glEnable(GL_TEXTURE_GEN_Q);    glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);    glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);    glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);    glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);    glTexGenfv(GL_S, GL_EYE_PLANE, PS);    glTexGenfv(GL_T, GL_EYE_PLANE, PT);    glTexGenfv(GL_R, GL_EYE_PLANE, PR);    glTexGenfv(GL_Q, GL_EYE_PLANE, PQ);    glPushMatrix();


Before render...
  glActiveTextureARB( GL_TEXTURE2_ARB);  glBindTexture(GL_TEXTURE_2D, id_texture_stages);  glEnable(GL_TEXTURE_2D);  glMatrixMode( GL_TEXTURE);  glPopMatrix();


and set in glsl
gl_TexCoord[2] = gl_TextureMatrix[2] * gl_Vertex;//i also try with gl_ModelViewMatrix


Any help?

Thanks in advanced
Neutrinohunter
Neutrinohunter
I'm new to GLSL but shouldn't it be
gl_ModelViewMatrix * gl_Vertex to but in the texture matrix?

glmisscelan
glmisscelan
I try
gl_TexCoord[2] = gl_TextureMatrix[2] * gl_Vertex;
gl_TexCoord[2] = gl_TextureMatrix[2] * gl_ModelViewMatrix * gl_Vertex;
gl_TexCoord[2] = gl_ModelViewMatrix * gl_MultiTexCoord2;
gl_TexCoord[2] = gl_ModelViewMatrix * gl_Vertex;
gl_TexCoord[2] = gl_TextureMatrix[2] * gl_MultiTexCoord2;

Nothing works, thanks anyway
glmisscelan
glmisscelan
Solved!
I must use texture2dProj instead texture2d. But now i found a glitch?? what is this????

description of your image

trippytarka
trippytarka
It looks like your wall is not a shadow caster...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.