GL_LIGHTING kills blending operations with glColor?

Blending is working fine until I enable lighting. It looks like glLightfv takes a 4 dimensional vector which overrides glColor*fv, so my vertex alpha values aren’t getting through. Is that right? How do you blend across vertices while using lighting?

Lighting doesn’t kill blending. What it does is write to the vertex colour, overwriting anything that was already there. Off the top of my head, there are a few ways to get around this: materials, textures, vertex shaders, multi-passing. . .

Thanks for responding. It must be materials that I’m after then. I’ll have to read more about lighting to understand materials and glColorMaterials.

I think ideally, the color resulting from lighting would be multiplied times the existing values in glColor. Is there a function like that in materials?

That’s basically what materials do. Specifically, the value from the colour (which lighting writes to) is multiplied by the material colour. The only problem is that materials are not specified on a per-vertex basis. Instead, materials affect an entire draw call.

I haven’t had a chance to code anything but I thought the purpose of glColorMaterials was going to be to allow the material color to be set per-vertex with glColor while lighting is enabled.

Ah! My appologies. . . I must admit that I’ve never had to use materials and largely skipped standard lighting. I went right into vertex and fragment shaders as soon as I could. :slight_smile:

Anyway, if GL_COLOR_MATERIAL is enabled, the material colour will be the vertices’ colour and the lighting will by multiplied with it. This is described in section 2.14.3 of the OpenGL spec.