Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Looking for the right blend mode

  1. #1
    Member Regular Contributor
    Join Date
    Sep 2002
    Posts
    384

    Looking for the right blend mode

    I have a dynamic light I am rendering as a decal on a wall in a second pass.

    -The light texture should only increase the brightness of the texture on the wall, not darken it.

    -The light should brighten the wall towards the full-bright color of the wall texture, NOT towards the white color of the light.

    -The wall is actually darkened because I rendered a second pass with a lightmap. Lightmapped surfaces are full-bright, just textured with a dark lightmap. They are not effected by GL lights.

    Right now I am using GL_SRC_COLOR,GL_ONE. This meets the first condition listed above, but it tends to gray-out the wall.

    See how gray this is?


    Here is a more visual display of what I am after.

    Start with the texture:


    This is the lightmap:


    Texture+lightmap with multiplicative blending:


    This is the decal:


    This is the texture+lightmap+decal, as it is now:


    And here is what I actually want. The decal lightens the lightmap, so the original texture shows through with its correct colors:


    It's worth noting that the lightmap and decal are at very different resolutions, so altering the lightmap is not a good idea.

    Thanks.

    [This message has been edited by halo (edited 12-19-2003).]

  2. #2
    Guest

    Re: Looking for the right blend mode

    If I understood correctly, you want to do :

    (precalc_lightmap + light_decal) * texture

    I would try multitexture (extension again...).
    See the glspec15.pdf, Figure 3.11 shows that you can use (CT0 + CT1) * CT2 .
    Or if you use multipass, render with precalc_lightmap, additive blend light_decal, then modulate with the texture.

    Hope it helps.

  3. #3
    Member Regular Contributor
    Join Date
    Sep 2002
    Posts
    384

    Re: Looking for the right blend mode

    It does help. I'm going to try to do it in 3 passes:

    1. No blend, render lightmap.

    2. Render dynamic light with glBlendFunc GL_SRC_alpha,GL_ONE

    Up until this point, the lightmaps are adding correctly.

    3. Now I want to render the actual texture, multiplying the combined lightmap and the texture. What BlendFunc do I use?

    [This message has been edited by halo (edited 12-19-2003).]

  4. #4
    Member Regular Contributor
    Join Date
    Sep 2002
    Posts
    384

    Re: Looking for the right blend mode

    I added a routine that cycles through all 81 possible blend modes. There doesn't seem to be any way to blend the texture in after drawing the two lightmaps. However, if the texture is drawn first, the second lightmap will blend with the result of the texture and first lightmap, resulting in loss of color.

  5. #5
    Guest

    Re: Looking for the right blend mode

    Do it this way :

    pass 1 : static light
    glDisable(GL_BLEND);
    <render static light>

    pass 2 : previous + decal light
    glEnable(GL_BLEND);
    glBlendFunc(GL_ONE,GL_ONE);
    <render decal light>

    pass 3 : previous*texture
    glBlendFunc(GL_DST_COLOR,GL_ZERO);
    <render texture>

    However, if your do really use alpha for material transparency, well, it will be complex without using multitexture extension.

    By the way, multitexture is supported by many old cards, at least with 2 texture units (Ati rage128, intel i810, NVidia TNT1,3dfx voodoo3). See http://delphi3d.net/hardware/index.php .

  6. #6
    Guest

    Re: Looking for the right blend mode

    And if you find that the final result is too dark , you can replace the third pass by :

    pass 3 : previous*texture*2
    glBlendFunc(GL_DST_COLOR,GL_SRC_COLOR);
    <render texture>

    So ?

  7. #7
    Member Regular Contributor
    Join Date
    Sep 2002
    Posts
    384

    Re: Looking for the right blend mode

    Something funny is going on here.



    [This message has been edited by halo (edited 12-19-2003).]

  8. #8
    Guest

    Re: Looking for the right blend mode

    A bit too bright
    Well, for pass 2, put back your :
    glBlendFunc GL_SRC_alpha,GL_ONE

    Do not use the 'boosted' pass 3 of course...

    Maybe use glBlendFunc GL_SRC_alpha,GL_ZERO for pass 1 as well...

    From your initial post pictures above I though you did not used alpha for your lightmaps, I must be wrong. Details on how luminance information is stored on decal and static lighting textures ?

  9. #9
    Member Regular Contributor
    Join Date
    Sep 2002
    Posts
    384

    Re: Looking for the right blend mode

    Got it!

    This looks great. The moving lights actually washes out the shadows, so it looks almost like dynamic shadowing:

    Click here to see it in action.

    Thanks to all who offered their help on this.



    [This message has been edited by halo (edited 12-19-2003).]

  10. #10
    Member Regular Contributor
    Join Date
    Aug 2003
    Posts
    264

    Re: Looking for the right blend mode

    wow, that looks pretty sweet. Are you using Catography Shop? It stores the lightmaps in the saved file, doesn't it?

Posting Permissions

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