Results 1 to 5 of 5

Thread: Multipass GL_ARB_multitexturing

  1. #1
    Member Newbie
    Join Date
    Dec 2000
    Posts
    44

    Multipass GL_ARB_multitexturing

    Need more help guys. Previously I was successful in multitexturing two textures: a base texture which covers an entire polygon and a decal which appears in a small area over the same polygon by using glTexEnv(,,GL_DECAL).

    So I thought what happens if I want to put on a base texture and two decals. My video adapter (Geforce MX) has two texture units. So I'll have to do this in two passes.

    glClearColor( gray )
    enable alpha testing
    glAlphaFunc( GL_GREATER, 0.5 )

    // Pass number one
    glActiveTexture( unit 0 )
    glBindTexture( base texture )
    glTexEnv(,,GL_DECAL)
    enable texturing
    glActiveTexture( unit 1 )
    glBindTexture( 1st decal )
    glTexEnv(,,GL_DECAL)
    enable texturing
    draw quad

    // Pass number two
    glActiveTexture( unit 0 )
    glBindTexture( 2nd decal )
    glTexEnv(,,GL_DECAL)
    glActiveTexture( unit 1 )
    glBindTexture( 0 ) // unbind texture
    disable texturing
    draw quad

    disable alpha testing

    The base texture and 1st decal has been wiped out (all white) and only my 2nd decal appears. What happened?

    Inserting glFlush() after pass one did not help.

  2. #2
    Senior Member Regular Contributor
    Join Date
    Sep 2000
    Location
    Lubbock, TX, USA
    Posts
    197

    Re: Multipass GL_ARB_multitexturing

    Technically, not even the second texture (tex unit 1) should be drawn, cause GL_DECAL==GL_REPLACE - so it should wipe out the first (tex unit 0) texture... the third decal texture is drawn over the quad as well and then replaces whatever is in the color buffer. Try using GL_MODULATE instead for the second pass and see what happens.

  3. #3
    Senior Member Regular Contributor
    Join Date
    Jun 2000
    Location
    B.C., Canada
    Posts
    367

    Re: Multipass GL_ARB_multitexturing

    GL_REPLACE != GL_DECAL

    When the alpha channel of a texture is fully opaque, they are the same. Otherwise they are different.

    GL_DECAL is blended in with the previous texture unit based on its alpha. GL_REPLACE simply replaces all information from the previous texture unit, including alpha.

    The reason you are seeing all white is because the background color of the quad is showing through your decal texture on the second pass. This means that to OpenGL, your quad is not transparent at all.

    Setting your mode to GL_REPLACE or GL_MODULATE will fix it.

    j

  4. #4
    Member Newbie
    Join Date
    Dec 2000
    Posts
    44

    Re: Multipass GL_ARB_multitexturing

    Thanks for the tip. GL_REPLACE & GL_MODULATE do work for the 3rd decal. OK, so one base texture and two decals works ... how 'bout one more decal?

    pass1.unit0.replace <-- base texture
    pass1.unit1.decal <-- 1st decal
    pass2.unit0.replace <-- 2nd decal
    pass2.unit1.decal <-- 3rd decal
    Didn't work. 2nd decal OK. Can't see 3rd decal. Ahhhhhh

    I've also tried these variations for pass2
    unit0.replace = not visible // gets crushed by 3rd decal
    unit1.replace = visible

    unit0.replace = not visible
    unit1.modulate = not visible

    unit0.modulate = visible
    unit1.decal = not visible

    unit0.modulate = not visible
    unit1.replace = visible

    unit0.modulate = not visible
    unit1.modulate = not visible

    I think those are all the possible combos. Can you guys help me one more time and I swear I won't ask for help again ... until the next time I need help.

  5. #5
    Senior Member Regular Contributor
    Join Date
    Sep 2000
    Location
    Lubbock, TX, USA
    Posts
    197

    Re: Multipass GL_ARB_multitexturing

    Originally posted by j:
    GL_REPLACE != GL_DECAL

    When the alpha channel of a texture is fully opaque, they are the same. Otherwise they are different.
    Oops... of course you're right.
    Sorry 'bout the wrong info

Similar Threads

  1. MultiPass with FBO
    By Brodrick in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 05-08-2011, 10:00 AM
  2. Multipass Rendering
    By iris_raj in forum OpenGL: GLSL
    Replies: 2
    Last Post: 05-18-2007, 12:12 PM
  3. FBO and multipass
    By divide in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 03-24-2005, 01:07 AM
  4. Multipass lighting and multipass texturing
    By Dodger in forum OpenGL: Advanced Coding
    Replies: 12
    Last Post: 07-02-2002, 08:34 AM
  5. Multipass rendering
    By Ysaneya in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 01-13-2001, 04:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean