Jump to content
  • Advertisement
Sign in to follow this  

Questing regarding decals in Deferred/Forward+ pipelines.

This topic is 743 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm currently deciding which kind of shading pipeline to get into. Now that I know the common pros/cons of forward and deferred shading, I'm leaning towards the Forward+ method for the sake of flexibility in materials and transparency (and there are only dozens of lights in my scene, for which I don't think it need to be deferred). But I also want decals which can add lots of interesting details to the scene. IIRC it can be done fast and cleanly with Screen Space Decal (or whatever it's called) with deferred. However as I read in several threads that modern forward shading can render decals too.
Is it true? If so, How is it implemented? I have searched around but found no material about how it's done. (most papers and articles focus on how to render thousands of lights in real time, decals is more likely to be an 'addon', rather than a core feature of the pipeline after all) Actually I found something that may be useful like what's used in Doom 2016, but it's still a little vague to me on how it's done specifically.
So below is my guess (in pseudo code):
CPU Side:
#in each frame
    construct data structures for all lights
    construct data structures for all decals
    for each object in scene:
    do post processing etc.
Shader (called for every object):
surfaceData = sample textures etc.

for each decal affecting this pixel:
    decalSurfaceData = something similar to Screen Space Decal
    surfaceData = blend(surfaceData, decalSurfaceData)

for each light affecting this pixel:
    BRDF = computeBRDF(light, surfaceData)
    outColor = blend(outColor, BRDF)
(so basically you do the same as what's done to lights to cull decals, and has two loops in the forward shader, one for decals, another for lights)
And just for my curiosity, How is decals handled in a 'classic' forward engine? Is it just some quads sticked onto the surface (and you have to deal with all kinds of problems like surface matching, Z-fighting etc.) ?
Edited by secondwtq

Share this post

Link to post
Share on other sites

What you've described is the gist of it. If you want to see a working implementation of these technique you can check out my deferred texturing demo. It uses DX12, and so it makes use of dynamic texture indexing to sample the approapriate decal texture data given an index. However you can also use texture arrays or atlases if you're working with a platform that doesn't support descriptor indiexing.


Old-school details were just transparents rendered on top of the opaque geometry. The hard part was constructing geometry that could do that without z-fighting, which was typically done by duplicating the opaque geometry and clipping. This presentation gives a quick overview of the problems of traditional decals, and also explains how projective decals can nicely avoid that issue. The other issue from old-school details is that you have too full shade, light, and blend the decals into your render target. A deferred decal avoids this entirely by apply the decal before lighting is computed, and also performs the blending in registers instead of in memory.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!