Search Unity

How is GBuffer handled in Unity?

Discussion in 'General Graphics' started by AlanGameDev, Jul 25, 2016.

  1. AlanGameDev

    AlanGameDev

    Joined:
    Jun 30, 2012
    Posts:
    437
    Hello there.

    I'm doing a comprehensive decals system. I plan to support many decal types including deferred decals, however, I see the 'old' deferred system won't allow you to do decals (properly) because ambient lighting happens in a pass before you can access it. I would like to know if the new deferred system still have such limitation, not only for ambient but also other buffer manipulations that could cause problems.

    Thank you.
     
  2. AlanGameDev

    AlanGameDev

    Joined:
    Jun 30, 2012
    Posts:
    437
    After a bit of research, I'm updating this for future reference:

    The new deferred rendering apparently didn't change anything concerning my points. Basically it's not possible to have proper deferred decals currently due the way the GBuffer creation works in Unity. This is a very complex matter and although in theory it's possible to 'workaround' the limitations, in practice it's not worth it because you'd have to perform a lot of calculations separately (e.g.: for lightmaps) so the overhead will be big, and who knows what kind of problems could happen. It's a HUGE job to achieve a bad result that will be totally irrelevant once Unity exposes a previous rendering state.

    UE4 for instance allows proper decal creation (DBuffer feature). Basically it renders the whole shebang up to a point that is suitable for decals and then renders the decals (which are a built in feature). In UE4 that is optional, since obviously there's a bit of overhead in buffer creation as opposed to the classical "full render" (unlit) GBuffer creation. Other features like tiling also have to be taken into account for an optimal system.

    I also have a feeling that when Unity introduce a proper rendering system suitable for decals it is going to provide deferred decals too, so for the time being I'm dropping my plans to support deferred decals.
     
  3. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    2,869
    For sure you can to deferred decals in the "new" deferred rendering mode.
    Check out this link, they have even a example of a simple defend decal.
    https://docs.unity3d.com/Manual/GraphicsCommandBuffers.html

    Commandbuffer open up a lot of possibility to dig into unity rendering pipeline and do interesting stuff.
     
  4. AlanGameDev

    AlanGameDev

    Joined:
    Jun 30, 2012
    Posts:
    437
    Thanks for your reply.

    Did you read the 2nd post?
    Unfortunately that chart can't be interpreted literally because that "Lighting" pass is actually only real-time direct light, and the GBuffer at that point already has other light types "baked" in it, so unfortunately no, currently it isn't possible to do decals properly. That link is quite useful though, and that scene would surely save me some hours if I knew it a couple days ago... in any case, the readme it includes explicitly states this:
    So, besides lightmaps and ambient there's also reflections.

    On personal a side note: I got relatives in Dusseldorf. Cool city. Although someday I was wandering around and ended up in the brothels district lol. I saw a building with a lot of stars and I went there thinking it was some kinda EU organization, only to realize it was a brothel...:eek: (well, they say there's not much of a difference anyway lol) I started to walk double-quick away from there before somebody approach me but I already was in the middle of the whole shebang. Luckily it was in the morning so I survived.:)
     
    Last edited: Jul 26, 2016