PDA

View Full Version : OpenGL pulsing lights


riksweeney
01-04-2007, 03:53 AM
Hi,

I'm loading up a BSP file (created in GTKRadiant) and am rendering the texture to the first texture unit and applying the lighting to the second texture unit. This all works OK.

In my game though, I want to change all the lighting to red which is OK as I can just copy each lightmap and convert it by altering the HSV and RGB values. I can then bind this to the second texture unit instead.

What I would like to do is be able to pulse between the original lightmap and the red one. I was considering using the 3rd texture unit and just fade between them, but this would cause problems to people with old cards. Making loads of textures to go on the 2nd texture unit probably isn't a good approach either.

Does anyone have any suggestions as to how I can blend between the two colours?

Thanks

Richard

Reedbeta
01-04-2007, 11:13 AM
If you're worried about cards that only have 2 texture units then I assume you also don't want to use pixel shaders (which would be the usual way to accomplish something like this), and are using the ARB_texture_env_combine (http://oss.sgi.com/projects/ogl-sample/registry/ARB/texture_env_combine.txt) interface. If that's the case, it seems to me you can do this by swapping the two textures - put the decal textures in the second unit, and the lightmaps in the first unit. For the first unit, configure it with the interpolate operation, with source0 being the texture, source1 the texture unit's constant color which you'll set to red, and source2 the texel primary color (which is set by glColor). Then have the second unit simply multiply the result by the decal texture. This way you can vary the primary color between 0 and 1 to effect a blend between the lightmap and the constant red lighting.

riksweeney
01-05-2007, 02:34 AM
Thanks for the link, using GL_MODULATE has achieved the effect that I wanted.

Thanks for your help!

Richard