Results 1 to 2 of 2

Thread: Blending Issue

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2010
    Posts
    1

    Blending Issue

    Hello all great board lots of stuff to be learned here!

    I have been having this issue for a while now and I can't seem to resolve it. I have an object that I am creating partly transparent via the texture. To do this I am masking, applying the texture I want to be seen, and a texture that has black where I want the texture solid and white where I want it transparent. It works great when there is no light enabled, but fails when light is. Well... not really the object is 2D and the side I make the normal on works fine when there is light on it, but not the other side.

    Maybe a screenshot would help:


    And my code:
    Code :
    glEnable(GL_TEXTURE_2D);
    glEnable(GL_BLEND);
    glDisable (GL_DEPTH_TEST);
     
    glBlendFunc (GL_DST_COLOR, GL_ZERO);
    glBindTexture (GL_TEXTURE_2D, texture[0]);
     
    glBegin (GL_QUADS);
    glNormal3f(0,0,1);
    glTexCoord2d (0, 0);
    glVertex3f (-1, -1, 0);
    glTexCoord2d (1, 0);
    glVertex3f (1, -1, 0);
    glTexCoord2d (1, 1);
    glVertex3f (1, 1, 0);
    glTexCoord2d (0, 1);
    glVertex3f (-1, 1, 0);
    glEnd();
     
    glBlendFunc(GL_ONE, GL_ONE);
    glBindTexture(GL_TEXTURE_2D, texture[1]);
     
    glBegin (GL_QUADS);
    glNormal3f(0,0,1);
    glTexCoord2d (0, 0);
    glVertex3f (-1, -1, 0);
    glTexCoord2d (1, 0);
    glVertex3f (1, -1, 0);
    glTexCoord2d (1, 1);
    glVertex3f (1, 1, 0);
    glTexCoord2d (0, 1);
    glVertex3f (-1, 1, 0);
    glEnd();
     
    glEnable(GL_DEPTH_TEST);

    Could someone please help me? Thank you.

  2. #2
    Senior Member Regular Contributor
    Join Date
    Nov 2003
    Location
    Czech Republic
    Posts
    317

    Re: Blending Issue

    I do not understand your concept of masking. But it seems to be too complicated.
    Your two pass code computes Result = Texture0*FrameBufferColor + Texture1; When lighting is enabled, then the colors are of course modified by light.

    Why don't you use RGBA texture and the most common blending function glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA). Your texture alpha channel should be black for pixels with full transparency and white for fully opaque pixels. The gradient between black and whites defines the level of transparency.

Similar Threads

  1. Point sprite alpha blending issue (Android / OpenGL ES 2.0)
    By georgi in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 07-28-2017, 04:58 AM
  2. Issue with blending
    By debinair in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 11-14-2013, 06:13 PM
  3. Replies: 4
    Last Post: 11-04-2013, 08:12 AM
  4. Replies: 1
    Last Post: 05-01-2013, 09:37 PM
  5. Layer composition, textures & alpha blending issue
    By viral in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 09-18-2009, 05:36 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