Metalness in DBuffer decals

Goals: Addendum

One thing I forgot: Once I have all of this working for dbuffer decals, I like to implement it for regular deferred decals, too. I actually started with those, but getting them to blend with instead of overwriting underlying materials turned out to be more complicated than I thought. Once I’m more familiar with Unreal’s render pipeline, I’ll have another go at it.

The rendering steps leading up to regular decals seem pretty clear to me: The gbuffer is filled during the prepass and the basepass, and right before lighting is applied, deferred decals are rendered on top of the geometry. You can see it in RenderDoc: No decals at one stage and all decals at the next.

Still, I need to do some more digging until I’ll be able to figure this out. The point is, I would like to have selective blending working not only for dbuffer decals, but for regular ones as well.

But Why?

Why would I want to do this when dbuffer decals already give me all I need? There are two reasons.

The first one is really simple as it can be explained by two numbers: 99 and 51. The default base material in its simplest form requires 99 instructions in the base pass if static lighting and dbuffer decals are enabled in the project settings (they are in a new blank project). The same material requires only 51 base pass instuctions if both options are turned off. That’s roughly half.

Which means that projects that don’t make use of static lighting can usually save a good number of shader instructions if they disable it. If you don’t use static lighting, though, there is usually no need to have dbuffer decals enabled, since their main (only?) advantage over regular decals is that they can be used with baked lighting. But if you wished to make use of selective blending in your decal material, you’d be forced to enable dbuffer decals only for this feature. And your game will be less performant because of it.

That’s reason number one why I’d like to implement selective blending for regular decals as well.

The second reason is that dbuffer decals still don’t provide access to the same material attributes that regular decals do, most notably the Emissive pin. There is no chance I will try to enable emission in dbuffer decals. Doing this would require adding another render target to the dbuffer which I want to avoid at all costs. As it stands, there is just no space left to fit the emissive information. The last remaining space that the dbuffer had to offer went into storing metalness.

Goode ol’ regular decals don’t suffer from this limitation and offer a more complete package as a result. Getting selective blending to work for them would offer people a perfomrant alternative for dbuffer decals in games that make use of dynamic lighting only.