Selectively blending

Started by
4 comments, last by mannam 21 years ago
Hello, Suppose I'm rendering a transparent object over 2 objects. Is it possible to use 2 seperate blending function for the 2 objects? For example i want object 1 to use glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) and use glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA) for object2. Thanks! Cheers, Man [edited by - mannam on March 17, 2003 10:02:19 PM]
Advertisement
I''m not very sure about this as I haven''t used blending a lot, but woudln''t you simply, before rendering Object1 set glBlendFunc(...) to whatever you need, and then before rendering Object2 change to Blendfunc??
Don''t know for sure though.

Thanks for replaying! RizMan

For my case, i want to render a particle system. But the background is too bright to use glBlendFunc(GL_ONE, GL_ONE). So i used glBlendFunc(GL_ONE, GL_SRC_ALPHA) to darken the background. Unfortunately the particles darken themselves each other...and it becomes a dark cloud...


[edited by - mannam on March 19, 2003 5:04:49 AM]
quote:Original post by mannam
Thanks for replaying! RizMan

For my case, i want to render a particle system. But the background is too bright to use glBlendFunc(GL_ONE, GL_ONE). So i used glBlendFunc(GL_ONE, GL_SRC_ALPHA) to darken the background. Unfortunately the particles darken themselves each other...and it becomes a dark cloud...


You could use two passes :

- First, render all your particles with (GL_ZERO, GL_SRC_ALPHA) with a 50% alpha, so that you darkenn the background. The 50% alpha is important since you certainly don''t want to darken it as much as you''ll brighten it.

- Next, render all your particles with standard additive blending (GL_ONE, GL_ONE)

Well, it''s just a quick though but it may work.
Try this:
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
I use it for my particle system, but I use 32 bit texture with
alpha map, transluency is great for this.


Thank you all!

I''d better try 2-pass-rendering. Thanks Prosper/LOADED!

This topic is closed to new replies.

Advertisement