Results 1 to 10 of 10

Thread: Make color transparent

  1. #1
    Senior Member Regular Contributor
    Join Date
    May 2004
    Location
    Renkum
    Posts
    193

    Make color transparent

    Hello
    I've loaded some pictures and used them as textures.
    But I want to look through one color in my hall scene(the color(1.0, 0.0, 1.0)), so i can see the underlieing texture.
    I think it should be done with blending and the alpha value, but I have no idea how to do it(the files that I've loaded don't support alpha values).
    If anyone knows how to do it, please let me know.
    Hylke

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Feb 2004
    Location
    Long Island, New York
    Posts
    569

    Re: Make color transparent

    The only thing I can think of is using a fragment program to filter out fragments of that color.

    In the fragment program you test the RGB value, it it's 1.0,0.0,1.0 you discard the fragment.

    You're right though, you should really use textures with an alpha channel.

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Jul 2001
    Location
    France
    Posts
    1,662

    Re: Make color transparent

    I think too that RGBA textures should be best.

    One solution consists on changing the format of your picture and do the work in order you color to be transparent (gimp can do that). TGA is a good format to manage transparency.

    Another solution would consists on modifying or adding new functions to your texture loader so that you can do the manipulations you want.

  4. #4
    Senior Member Regular Contributor
    Join Date
    May 2004
    Location
    Renkum
    Posts
    193

    Re: Make color transparent

    Ok, thank your for your replies.
    But the reason i did not used a file with alpha values support was i did not get the effect i wanted.
    I've loaded the image using QTs QImage class, but when i display the texture it's black where it should be transparent(the color of the QUAD is (0.0, 0.0, 0.0, 0.0) that should be completly transparent).

  5. #5
    Senior Member Frequent Contributor
    Join Date
    Feb 2004
    Location
    Long Island, New York
    Posts
    569

    Re: Make color transparent

    If the surface you're mapping your texture onto has an alpha of 0.0 you won't see anything.

    try using a color of (1.0,1.0,1.0,1.0) and using GL_MODULATE to do your texturing for starters.

  6. #6
    Senior Member Regular Contributor
    Join Date
    Aug 2003
    Posts
    369

    Re: Make color transparent

    also, have you enabled blending and defined a blending function?
    use glEnable(GL_BLEND);
    and check out manual on glBlendFunc();

  7. #7
    Senior Member Regular Contributor
    Join Date
    May 2004
    Location
    Renkum
    Posts
    193

    Re: Make color transparent

    Ok, thanx
    I've now enabled blending, and have set the texture combining thing to GL_MODULATE, changed the quad color to (1.0, 1.0, 1.0, 1.0) and my blending function looks like this:
    Code :
    	glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
    But when i run the program, everything is much lighter and looks kinda different.
    So how can i have the original colors but still a transparent picture?
    Thanx Hylke

  8. #8
    Senior Member Regular Contributor
    Join Date
    Aug 2003
    Posts
    369

    Re: Make color transparent

    Try using this for blending:
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    might be what u want. Also remember to turn off blending when you don't need it (and it's also good practice to draw your transparent objects last in your display function)

  9. #9
    Senior Member OpenGL Pro
    Join Date
    Jul 2001
    Location
    France
    Posts
    1,662

    Re: Make color transparent

    Try GL_DECAL instead of GL_MODULATE.

  10. #10
    Senior Member Regular Contributor
    Join Date
    May 2004
    Location
    Renkum
    Posts
    193

    Re: Make color transparent

    that GL_SRC_ALPHA and GL_ONE_MINUS_SRC_ALPHA did the trick.
    Thanx Hylke

Similar Threads

  1. Replies: 2
    Last Post: 11-23-2011, 04:30 AM
  2. How to make some color in texture transparent ?
    By jirkamelich in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-27-2002, 05:46 AM
  3. How do I make the screen color transparent?
    By songeb in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 12-18-2001, 06:14 AM
  4. code for make black color of BITMAP (bmp) transparent...
    By MofuX in forum OpenGL: Basic Coding
    Replies: 11
    Last Post: 08-26-2001, 07:15 AM
  5. Make one spec. color appear as Transparent
    By Dingo in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 04-02-2001, 09:48 AM

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