[State]
To Be Continued...
[Conception]
Blending
[URL]
http://www.learnopengl.com/#!Advanced-OpenGL/Blending
[Contents]
...
Blending in OpenGL is also commonly known as the technique to implement transparency within objects. Transparency is all about objects (or parts of them) not having a solid color, but having a combination of colors from the object itself and any other object behind it with varying intensity. A colored glass window is a transparent object; the glass has a color of its own, but the resulting color contains the colors of all the objects behind the glass as well. This is also where the name blending comes from, since we blend several colors (of different objects) to a single color. Transparency thus allows us to see through objects.
Blending |
...
[ Orders Of Rendering]
...Blending Basics |
There are some things that deserve attention.
Look at the order of rendering.
First we rendered objects that are fully opaque, and then we turned the blending on to render the transparent objects. And not only that, we called function glDepthMask(0) to turn off writing to depth buffer, and after the rendering glDepthMask(1) to restore it.
Why doing that?
Let's take an example: We want to render one opaque cube, and two transparent cubes in front of it After rendering opaque cube, we don't want to write values to depth buffer, because if there are two transparent object that pass Z-test, second transparent object can get behind the first, and after altering the depth buffer values with rendering the first transparent object, the second may not pass Z-test and thus won't be rendered at all. But since these objects are at least partially transparent, the second object should be visible as well. That's why we turn depth buffer writing off.
Important lesson to take here is to pay attention to order of rendering - first opaque, then transparent with depth buffer writing disabled....
[]
...
...
[]
...
...
[]
No comments:
Post a Comment