Hi all.
As some might have noticed in previous posts, I've been working on a
deferred rendering pipeline for my engine.
I'm up to the phase where I'd like to have decals on the system.
The way I see it, there's two different ways to implement decals on deferred
rendering:
1) The decals operates on the G-Buffer
2) The decals operates on the frame buffer
The pros/cons I see in operating on the G-Buffer are:
- Can get correctly lighted normal/emissive/specular mapped decals
- Can't have blend operations on the decals (writing on the
G-Buffer has lots of data of different types, not all affected in the same
way, so alphablending or any other blend operation could spoil my data). So
all decals would have to "replace" what's already on the G-Buffer.
The pros/cons I see in operating on the frame buffer (the already lighted
scene, pre-glow pass):
- Without checking the decal for every light, can't get lighted
decals
- Can't do decals that glow/remove glow from the scene (the glow
intensity is on the G-Buffer, so that's what's used on the glow pass).
- Blending operations are easier to define and control (and
possible without hocus-pocus)
At first sight, I'd say that operating on the G-Buffer is much simpler and
allows for more flexibility, but I still get the gnawing feeling that the
lack of alpha blending operations will bite me in the ass.
Consider these three decal types: bullet holes, footprints and plasma
residue.
On bullet holes, under the G-Buffer approach, I'd change the albedo of the
G-Buffer to a dark gray/black, while changing the normals to distort the
lighting on the bullet hole. On the frame buffer approach, I'd have to use a
subtract blending operation to darken the "wall" in the shape of the bullet
hole, without any distortion to the normals. The visual result might be good
in both cases.
On the footprints, for the G-Buffer approach, I'd have to just change the
normals to account for the footprint, without any change to the albedo,
which would be a realistic footprint in "muddy" environments, but I think it
would look silly in a dusty environment, which would be better done with an
albedo change to dark-brown or something like that, which might look
incorrect if the dust was on a metal floor. On the frame buffer approach,
I'd just have to alphablend a mid-alpha black texture in the shape of a
foot, using the alphablending hardware to get the correct footprint color on
different floors. It wouldn't look so good in muddy environments, but even
so it would look great.
On the plasma residue, I'd change the albedo and emissive component on the
G-Buffer to green and "high", which would lead to a glowy green goo on where
the plasma hit. On the frame buffer approach, I could only add a green color
to the frame buffer in the shape of the plasma residue, which wouldn't glow.
So, both approaches can be good or bad depending on what you're trying to
achieve. I even thought about having two kinds of decals (one that affects
the G-Buffer and another that affects the frame buffer) for different
usages, but to be honest I'm kind of at a loss on how to proceed.
The implementation seems pretty straightforward in both cases, it's just a
matter on where it goes in the pipeline, and all my searches on the Internet
been fruitless, since apparently nobody discusses decals at this level (only
building them and rendering them in the most primitive form).
So my question is: how do you guys handle decals in a deferred rendering
context? Any ideas, suggestions, pointing-at-and-laughing appreciated!
Thanks in advance
Diogo de Andrade
|