[Deferred decals] Specular channel modification in BeforeLightning pass

Hello everyone,
I’ve been unsuccessfully trying to fix an issue in our game related to deferred decals.

The point is, I want like to overwrite specular channel with black, so that our decals are not affected by the underlying surface (just like I can do with albedo and normals).

This is the decal on the surface with zero specular:

and the corresponding specular channel:

Now with the underlying surface outputting specular >0:

and the corresponding specular channel:

We’re using an altered version of the deferred decals released by Unity. This version also grabs the “BuiltinRenderTextureType.GBuffer1” channel (specular/smoothness) and writes to it in the decal shader.
This works perfectly, except for surfaces that output specular color >0.
I don’t have deep knowledge of the whole deferred path implementation Unity uses, but from what I’ve seen, it seems that the color I output to the GBuffer1 channel is additively blended with that of the underlying surface.
Shouldn’t the opaque geometry be already drawn in this pass? This works for normals, as the decal shaders blend it’s own normals with the ones already in the GBuffer2.

Is it possible to overwrite the GBuffer1 after all the opaque geometry has output it’s specular color to it?
How is it that this works for albedo/normals?

Thanks in advance to anyone replying. :slight_smile:




I’m not exactly sure what your problem is. Best I can tell the specular for the blood is not addative, but blended.

Without more information, such as shaders, I have a very hard time guessing what could be the cause.

In your screenshot where you say the grounds specular is > 0, it seems that everything is washed out, even outside the decal.

Yes, it indeed seems as if the specular was blended, which is confusing for me, as I thought I was rewriting the buffer, not writing to some other buffer which would then be blended with the original. It’s also strange that other buffers, such as albedo and normals can be fully overwritten, with no blending whatsoever.

Have you checked what alpha value you are outputting for that buffer?