Other graphics buffers

BlitzMax Forums/BlitzMax Programming/Other graphics buffers

Czar Flavius(Posted 2011) [#1]
I've found in the graphics code some extra buffers and found this thread:

http://blitzbasic.com/Community/posts.php?topic=75618

But I'm still not sure what this buffers mean or are for.

First of all, which of these can practically be used with both opengl and directx using regular max2d without messing around?

Secondly, could you give some practical examples of their use?

I'm particularly interested in the alpha buffer. What can I use it for?

Thanks.


Gabriel(Posted 2011) [#2]
The alpha buffer just means that the framebuffer has an alpha channel. It's very often used for post processing effects. When you draw things to the screen, it's very cheap to write something "extra" in the alpha channel since you're already drawing all those polygons anyway. So if, for example, you were using a post processing effect like a glow, you could have the amount of glow of each pixel determined by the value in the alpha channel of the frame buffer. That way you could stop things glowing, tone them down, or make them glow even more, just by changing the value they write to the alpha channel. Precisely what you put there would depend on the exact nature of the post processing effect.


Gabriel(Posted 2011) [#3]
I'm not big on OpenGL, but the accumulation buffer - as I understand it - is exactly what it sounds like. It's a special high-precision framebuffer which is used for composition. These days a lot of games with high-end effects have to compose the final framebuffer from a number of different sources. When you're doing complex stuff like depth-of-field, SSAO, etcetera, these effects can't just be rendered in one pass. So you typically want to combine your different passes into one final framebuffer, and the accumulation buffer is where you do the composition.

The stencil buffer can be a buffer in its own right, but it's usually part of a combined depth and stencil buffer. The most basic use of the stencil buffer is to control where things are and are not rendered (ie: like a stencil) but because it's used in combination with the depth buffer, they can be combined to product more complex effects. Two of the most common uses of the stencil buffer are shadows and planar reflections. You can create all kinds of complex effects with them though. Portals can be rendered this way (as in Prey*) as can various post process effects similar to Photoshop filters.



*Quite possibly in Portal too, but I haven't played it.


Czar Flavius(Posted 2011) [#4]
Thank you for your explanations. Could you provide sample code of how to read data from the alpha buffer? As I don't know how to actually use it. Thanks.


Gabriel(Posted 2011) [#5]
I'm sorry, I've never had cause to do it. I only know that this is how and why it works because it's how Unity allows you to control the glow post-processing effect.

There seems to be some discussion (and code) here which might help:

http://www.blitzbasic.com/Community/posts.php?topic=45207