-
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?
-
Member
Regular Contributor
Re: GL_LIGHTING kills blending operations with glColor?
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. . .
-
Re: GL_LIGHTING kills blending operations with glColor?
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?
-
Member
Regular Contributor
Re: GL_LIGHTING kills blending operations with glColor?
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.
-
Re: GL_LIGHTING kills blending operations with glColor?
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.
-
Member
Regular Contributor
Re: GL_LIGHTING kills blending operations with glColor?
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.
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules