Jump to content

  • Log In with Google      Sign In   
  • Create Account


Blending woes


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 griffenjam   Members   -  Reputation: 193

Like
Likes
Like

Posted 05 November 2001 - 07:58 AM

I am using blending but am having some serious problems with a few objects that overlap but shouldn''t be blended. If two things have an alpha value of 1.0f how do I make one simple overlap the other one and not blend? Jason Mickela ICQ : 873518 E-Mail: jmickela@sbcglobal.net ------------------------------ "Evil attacks from all sides but the greatest evil attacks from within." Me ------------------------------

Sponsor:

#2 mkaltner   Members   -  Reputation: 122

Like
Likes
Like

Posted 05 November 2001 - 08:53 AM

turn blending off when drawing those objects.

glEnable(GL_BLEND);
glBlendFunc(...);
// draw blended objects

glDisable(GL_BLEND);
// draw non-blended objects

- Mike

#3 masonium   Members   -  Reputation: 118

Like
Likes
Like

Posted 06 November 2001 - 04:56 PM

Everybody keeps saying that you should draw the opaque objects first. Then draw the blended objects from furthest to nearest. There''s some kind of logic behind that, but I have no idea what it is.

#4 Scarab0   Members   -  Reputation: 122

Like
Likes
Like

Posted 06 November 2001 - 07:35 PM

Well here''s the procedure:
1) Turn on the depth buffer, depth writes and depth testing. (The latter two are enabled by default if the depth buffer is enabled.)
2) Turn of blending and draw all your opaque objects, preferably in front-to-back order but that''s not necessary.
3) Disable depth writes.
4) Turn on bledning and draw all transparent objects in a back-to-front order. Order is very important here!

Now here''s the logic.
Drawing your opaque objects from front-to-back decreases the amount of unnecessarily rendered pixels. If you render a cube in the background, and then another object in the foreground that obscures it, then you wouldn''t need to draw all those cube pixels.
When blending, we don''t want to write to the depth buffer because transparent pixels should not obscure other pixels entirely. We do keep depth testing enabled because we do want transparent pixels to be obscured by opaque pixels.
The rendering in front-to-back order is necessary for proper blending. If a destination pixel is in front of your pixel to be rendered, you''ll need another blending function than when it''s the other way around. This is not possible in OpenGL in a single pass, so it is better to sort your objects to prevent it from happening.

Did that help?

Dirk =[Scarab]= Gerrits




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS