Transparency?

Started by
2 comments, last by mkaltner 22 years, 8 months ago
Well, I''ve been reading through the OpenGL Game Programming book and I noticed that it doesn''t talk much about 2D (or 3D for that matter) transparency. It states that there are several blend functions and to use each of them to find new effects. It also states that transparency is the result of subtacting the source from the destination (or vice versa?) polygons but what exactly are they? Is the source polygon the first one drawn? It seems to me that the first one would be the source and the second the destination but an explanation would be nice... And this kind of thing happens a few places in the book really, somewhat annoying. Don''t just say, "Do this and you''ll get this result" without explaining exactly why... Well anyway, back to my question. Anyway able to explain this transparency thing a little better? - Mike
"The important thing to remember when programming is: When you're 90% complete, there's still 50% more to go."
Advertisement
oki, its quite simple really.
source is the incomming fragment ( ie the pixel that is about to be drawn to the framebuffer), and destination is the fragment that is allready there (ie the current value of the pixel at the location of the incomming pixel about to be drawn in the frame buffer).
The actual blend equation used by openGL is: -
Red(source)*Source(RedFactor) + Red(dest)*Dest(RedFactor)
and so on for the other channels.
The params to glBlendFunction, set what is used for the source(RedFactor) and dest(redFactor),( and obviouly the factors for the other channels). Simple example, glBlendFunc(GL_ZERO,GL_ONE) would be like this: -
Red(source)*0 + Red(dest)*1.
Also if your implementation supports it you can change the above equation by calling glBlendEquation(), this is part of the openGL 1.2 imaging subset so you may have to call it in extension styleeee.
hope thats of some use.
i thnk its time for nehe.gamedev.net!
check my site theres a demo that lets u play around with the blending methods + shows the math behind it

This topic is closed to new replies.

Advertisement