Archived

This topic is now archived and is closed to further replies.

Alpha blending - Beginner question

This topic is 6166 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Im kinda new to openGL codin'' so im sure the ansver to my question is trivial, but anyway... Im doing som simple blending with particles (two triangles with texture) It works fine when i have a dark background. But i need to use white as the background color, and therefore have the white become translucient and the black visible. How do you do this in OGL? I use ".sgi"s (mac), would it help to use an image format like tga with alpha channel? Thanks Johan

Share this post


Link to post
Share on other sites
The color of the background doesn''t matter, but rather the contrast between the colors do. An alpha blend is going to reduce the contrast so if the contrast is low to start with it is going to be even harder to see it. A white particle against a white background has a contrast of zero and is going to be invisible because any color blended with itself is that color no matter the transparency level. If dr, dg and db are the differance in the red, green and blue, mr, mg and mb are the maximum red, green and blue then your contrast is (abs(r1-r2)/mr + abs(g1-g2)/mg + abs(b1-b2)/mb)/3 as a percentage of possible contrast. A 50% transparency will reduce that to one half, 0% will leave it unchanged and 100% will make it zero. It is the contrast that determines how difficult it is to see an object, i.e. you can''t see a perfectly transparent object.

Share this post


Link to post
Share on other sites
i can''t remember exactly how to do this, but i think if you use glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) it does it... its something like that - i usually mess around trying various parameters til it works

alistair

Share this post


Link to post
Share on other sites
quote:
Original post by alistair b

i can''t remember exactly how to do this, but i think if you use glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) it does it... its something like that - i usually mess around trying various parameters til it works

alistair


Hmm, doesn''t seem to work, looks better but i''m not quite there... Any other ideas how to do this? I''ve tried all the glBlendFunc(GL_SRC_ALPHA, XXXX) funktions. Perhaps im doing something else wrong.

Share this post


Link to post
Share on other sites