PDA

View Full Version : Question about texture mapping



chun0216
09-28-2011, 02:23 AM
Hello,

I have a question about texture mapping in my program.
I was able to implement Projective Texture mapping correctly in which I load an image and use that as a texture for projection.
The question is that depending on where my camera is or in other words when the texture is out of range [0,1], the texture repeats.
In order to handle this, I used glTexParameteri with GL_CLAMP on both s and t. It seems working but now, another question is that it will look something similar to this:
http://cs.ucsb.edu/~chun0216/1.jpg
I want my texture to show only the lower left without having those vertical or horizontal stripes...
So something like this:
http://cs.ucsb.edu/~chun0216/2.jpg
So I am using GLSL to compute projective texture coordinate and use texture2DProj to draw it.
Is there anyway I can do this? Could someone help me on this?

Thank you so much!

Onumis
09-28-2011, 07:51 AM
Maybe you can manually set all texels in the border of the texture to black?
Or set them with max transparency.

mbentrup
09-28-2011, 09:10 AM
Set the clamp mode to GL_CLAMP_TO_BORDER instead and specify a black border color.

chun0216
09-28-2011, 04:01 PM
Thank you so much! That's what I wanted it and it worked perfectly! :)