Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: GL_LIGHTING kills blending operations with glColor?

  1. #1
    Intern Newbie
    Join Date
    Jun 2005
    Posts
    42

    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?

  2. #2
    Member Regular Contributor
    Join Date
    Jan 2003
    Location
    Edmonton, Alberta, Canada
    Posts
    322

    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. . .

  3. #3
    Intern Newbie
    Join Date
    Jun 2005
    Posts
    42

    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?

  4. #4
    Member Regular Contributor
    Join Date
    Jan 2003
    Location
    Edmonton, Alberta, Canada
    Posts
    322

    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.

  5. #5
    Intern Newbie
    Join Date
    Jun 2005
    Posts
    42

    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.

  6. #6
    Member Regular Contributor
    Join Date
    Jan 2003
    Location
    Edmonton, Alberta, Canada
    Posts
    322

    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
  •