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 2 of 2

Thread: absolutely weird blending problem

  1. #1
    Junior Member Regular Contributor karx11erx's Avatar
    Join Date
    Nov 2006
    Posts
    193

    absolutely weird blending problem

    I am currently implementing per pixel lighting and have created shader programs that can process up to 8 lights per pass (including a lightmap). If there are more than 8 lights for a face, multipass rendering is applied with glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_COLOR) to minimize saturation.

    Now as soon as multipass rendering kicks in for a face, the face gets pretty dark instead of brighter as I would expect for that blend mode. Particularly the lightmap doesn't seem to have an influence on the face's color (lightmaps only get rendered during the first pass). Same happens with GL_ONE, GL_ONE which imo should lead to color saturation pretty quickly.

    The weird thing about this is that the problem gets worse if more lights are rendered per pass and disappears if only one light per pass gets rendered (in which case blending works fine).

    This is when only the first pass is being rendered: The floor face to the left of the Z shaped wall panel is properly lit (no lightmaps involved here).

    good blending

    This is with 6 lights/pass, 11 lights total. The floor face to the left of the Z shaped wall panel lacks the green tone coming from the panel. I'd have it expected to be just somewhat darker.

    faulty blending

    Any ideas?

    I can post code if required.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Sep 2004
    Location
    Prombaatu
    Posts
    1,401

    Re: absolutely weird blending problem

    Use e.g. floating point render targets to sum the light, then a tone mapping operator to map the final scene into a displayable range. Pretty standard practice nowadays. Search for HDR rendering.

    Btw, use additive blending when summing light contributions, else your results, while they may be in range, are likely to be totally wrong (or more wrong than they would be otherwise).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •