PDA

View Full Version : Problem Aligning Textures



cpsmusic
01-19-2006, 08:24 AM
Hi,

I'm having a problem with texture alignment.

I've got a large textured wall that has a lamp on it. When the lamp is off everything is ok. When the lamp is on, I need to display a lightmap around the lamp. I've done this as follows:

When the lamp is on, I draw a quad around the lamp (slightly offset from the wall), and then apply the wall's texture and then the lightmap.

I've managed to get this working, however due to the position of the lamp, the texture applied to the lightmap's quad doesn't align with those on the wall surrounding it.

Is there some way to draw the texture from, say, halfway along one axis to 1 1/2 times along the same axis?

Unfortunately, moving the lamp is not an option.

Cheers,

Chris

dorbie
01-20-2006, 12:43 PM
Use GL_CLAMP_TO_EDGE for the wrap filtering to stop the light map repeating, make sure the lightmap has constant color dark outline matching the unlit portion of the image. Specify texture coordinates required to position the lightmap in teh correct place. You can specify different texture coordinates fro the wall texture and the light map, and you can do this while applying both the wall texture and the light map to a single polygon in a single pass. It's called multitexture.

dorbie
01-20-2006, 12:52 PM
P.S. I think I understand your question a bit better.

The solution is, when the light is on draw it with the SAME polygons as are in the wall with the light map applied and use those same texture coordinates for the second use of the wall texture. Use the clamping I described earlier to limit the light to the region about the light, whether it's an alpha texture technique or color modulation you use.