PDA

View Full Version : multitexturing + lighting problems



blt8
04-26-2002, 08:52 PM
i have a terrain to which i recently have added multitexturing. however, now my lighting does not work. i believe my problem lies in:

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

that is one of the texture properties i am using for my detail texture. it seems as if GL_REPLACE overrides lighting color values. i have tried using GL_MODULATE, but things become too dark, GL_BLEND does not create the effect i want, and GL_DECAL is pretty much like GL_REPLACE. anyone know how to get my lighting to work with multitexturing? thanks in advance.

Bob
04-27-2002, 01:27 AM
All you have to do to get lighting to work with multitexturing, is to enable lighting. Your problem is that you don't get the result you exepct, and since you don't tell us what you expect, we can't tell you what to do to.

blt8
04-27-2002, 09:03 AM
i had lighting working prior to the time i added multitexturing. what i expect is a multitextured lit terrain. thanks.

Bob
04-27-2002, 09:29 AM
A lit multitextured terrain, right. But there are a few equations to combine two textures with the primary color. I was asking how you want the two textures to be combined with the light. Is the second texture a detail map, or just another ground texture you want to modulate with the first texture? If you forget about lighting for a second, what do you want to do with the two texture? Multiply them, or add them, or anything else?

Then, how do you want the light to affect the textures, and which texture do you want it to affect? Only the first, or both?

Multitexturing and lighting is not an easy task. It's not the most difficult either, but it sure requires some knowledge about mutlitexturing, texture functions, and similar stuff. How much do you know about this?

If you feel comfortable with it, you should have a look at the texture env combine (http://oss.sgi.com/projects/ogl-sample/registry/ARB/texture_env_combine.txt) extension. It allows you to combine some quite nice equations for multitexturing.

blt8
04-27-2002, 11:23 AM
i have one primary texture that is mapped over the entire terrain (not tiled). the second texture is a detail texture. i would need to see the results of lighting affecting only the terrain texture to evaluate whether or not it is suffience. if not, then having lighting affect both textures is the only obvious alternative. i didn't realize multitexturing + lighting would be difficult...sorry.

zed
04-27-2002, 01:23 PM
look at
modulate with a bias of *2
or add_signed ie A+B-0.5 (prolly better for detail texture make grey 0.5,0.5,0.5 = no change less than 0.5 darken >0.5 brighten)

Bob
04-28-2002, 02:26 AM
As zed says, a detail texture should use the add signed operation. If your detail texture is grey (might work RGBs also, never tried), you can open it in some paint program, and apply an emboss filter on it. You then have a texture whose main color is 50% grey.