Results 1 to 5 of 5

Thread: Alpha blending problem

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2000
    Location
    Osby, Sweden
    Posts
    15

    Alpha blending problem

    In my engine i must render the transparent polygons after i rendered the other polygons. If i dont do that i can only see some of the other polygons thru my transparent polygon.
    It seems like an sorting problem or something.
    Or must the transparent polygon always be putted in after all the other solid polygons?

    Sorry for my bad english.

  2. #2
    Senior Member Regular Contributor
    Join Date
    Feb 2000
    Posts
    154

    Re: Alpha blending problem

    Yes, I think so. First you draw your non transparent things then you draw transperant things back to front.

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Alpha blending problem

    The reason why you have to draw the transparent polygion after all other polygons, is that the z-buffer is updated when you draw a transparent polygon. So if you draw a solid polygon behind a transparent one, you can't see because it fails z-buffer tests.

    Maybe it's possible to disable z-bufferupdates (but still test z-buffer when drawing) when you draw a transparent polygon...

    Bob

  4. #4
    Guest

    Re: Alpha blending problem

    Something like this should work (assuming that you're using a depth- (Z) buffer):

    1. Draw opaque objects with depth-buffer writing ON

    2. Disable depth-buffer writing

    3. Draw transparent/translucent objects. Objects will be tested against depth-buffer but no values will be written to it.

    4. Enable depth-buffer writes

    I.e.

    TheDrawFunction() {
    ...
    DrawOpaqueObjects()
    ...
    glDepthMask(GL_FALSE);
    ...
    DrawTransObjects();
    ...
    glDepthMask(GL_TRUE);
    ...
    }

  5. #5
    Guest

    Re: Alpha blending problem

    I forgot - using the scheme above the z-order of opaque and transparent/translucent objects is not important, but ... Depending on what kind of transparent objects you are drawing, the individual order of transparent objects might be important (since you're not updating the depth-buffer).

    (Oh, I also forgot a ";" behind DrawOpaqueObject(), but I guess you noticed that)

Similar Threads

  1. Alpha blending problem
    By MSobiecki in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 10-22-2006, 09:30 AM
  2. alpha blending problem
    By 0stress in forum OpenGL ES
    Replies: 1
    Last Post: 10-06-2006, 10:14 AM
  3. alpha blending problem
    By 0stress in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 09-29-2006, 06:47 AM
  4. Alpha blending problem
    By chennes in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 01-24-2002, 06:12 AM
  5. alpha blending problem
    By ill bandit in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 06-28-2000, 01:32 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