Deferred Rendering Alpha Blending/Transparency Issue.
#1 Members - Reputation: 515
Posted 01 February 2012 - 01:55 PM
#2 Senior Moderators - Reputation: 3113
Posted 01 February 2012 - 02:08 PM
When you initially create the g-buffer you render the opaque set of objects to the scene to your g-buffer, this includes details like: Depth, Normal, Texture, and specular data. Since all the objects initially rendered are opaque you don't have to worry much about ordering or "alpha", its just not present at all.
You then render your light buffer, which will typically use the z-buffer from the g-buffer stage to filter out the portions of the light geometry that are not visible.
Your final stage of the deferred renderer combines the two previous stages to produce the output buffer.
Now, in this entire process the ORDER and DEPTH of the objects is pretty much irrelevant, but when you attempt to render transparent objects you need to know both. This is typically why transparent objects are z-sorted. You need to know the depth of each transparent object because a light can be visible from behind the object, or from the front of the object, and if you have two transparent objects in a row then the order in which they apply their filters will change the output light. As a simple example, look at the attached image, note how 3 is different from 4, even though both are the same filters applied one on top of the other...BUT THE ORDER IS DIFFERENT.
This is information that is not easily stored in the g-buffer.
In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
ScapeCode - Blog | SlimDX
#4 Members - Reputation: 515
Posted 01 February 2012 - 03:03 PM
#5 Moderators - Reputation: 5416
Posted 01 February 2012 - 04:45 PM
So if we were to used depth peeling and peel each layer depth factor/color, we can always always composite them together at the end. But something like that would take a tons of memory since each layer of depth/color would require an additional G Buffer.
Yeah, it's doable but expensive. Humus has a demo on his website. You can also do tricks like stuffing alpha layers in MSAA subsamples.
#6 Members - Reputation: 515
Posted 01 February 2012 - 05:27 PM
#7 Members - Reputation: 1382
Posted 01 February 2012 - 07:10 PM
The mecha demo from AMD demonstrates how to do it properly for transparency:
http://developer.amd.com/samples/demos/pages/ATIRadeonHD5800SeriesRealTimeDemos.aspx
by first storing all fragments in the gbuffer (they use linked lists), then shading, then blending (although they use just forward shading in that demo)
ILM does it also in a tool, it's the "uber" version of this idea
http://people.csail.mit.edu/jrk/lightspeed/lightspeed_thesis.pdf
#8 Members - Reputation: 1281
Posted 02 February 2012 - 12:18 PM






