View Full Version : Lighting / texture / alpha problem
02-22-2003, 11:19 AM
Ok. So. I want to be able to use the basic color (via glColor3xx) to modulate the final texture fragment. If I don't use lighting, it's ok, but if I enable lighting, it doesn't work anymore. I tried materials (thru glColorMaterial), and enabled it only for diffuse channel. But for some reason the lighting is not working... no "shadows"... as if it would modify the ambient channel as well. If it helps, I'm using a GF4Ti4200 with the lastest drivers Sparkle gave out.
Please guide me, I really need to use all them things, especially set the final alpha thru glColor.
PS: I don't actually use glColor functions, I'm using Varrays.
02-22-2003, 02:02 PM
Well, it sounds like you are trying to multitexture an object with the glColor values and light it up in the same pass...
Pixel values change colors with lighting, so when you use lighting your darkers pixels (shadows) will work as if they were part of the glColor function call with a dark value; hence you get the textures all mixed up and no lighting.
If this is the case that you are trying to multitexture an object with glColor value and light it up, you might want to use a two pass with blending. So, you would first make your texturing work, and in the second pass you light it.
02-23-2003, 08:51 AM
I don't think that would be necessary. The fixed-function fragment coloring pipe is flexible enough to do what vladv and you describe.
Take a look at the fragment shading pipe. It consists of one (or two, for separate specular) color coming out of "lighting", going through a successive set of texture environments, and coming out the rear end where it goes into fog and blend. The key to realize here is that Color() specifies the incoming color, if you don't have lighting turned on, whereas the lights and materials (which can be specified with ColorMaterial()) generate the incoming fragment color when lighting is turned on.
The specific operations applied to fragments in each texture stage are defined by the TexEnv parameters, and may include GL_MODULATE, GL_ADD, GL_COMBINE, etc. Note that this is a distinctly different model from the one used in framebuffer blending, which happens at the very end of the fragment pipeline, and is specified with BlendFunc().
All of this belongs to the very basics of the OpenGL graphics pipeline, and certainly shouldn't be necessary to explain on the Advanced board, though. It's also well explained in both red and blue books.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.