Convention for GBuffer by add-ons

  • microdee
  • Topic Author
More
2 years 2 months ago - 2 years 2 months ago #1 by microdee Convention for GBuffer by add-ons was created by microdee
Now that we have addons that of course opens up the capability to get extra info about the scene in games or engines using deferred lighting (implemented of course on a per-game/per-engine basis), it would be a great to start a discussion about a unified way to get them in shaders, both on addon side and on shaders side. It's just simple naming really but some confusion and extra ifdeffing can be avoided in the future for shaders which can benefit from not calculating GBuffer data from depth (AO/GI stuff, Reflections, etc...).

I propose addons providing GBuffer announce their capability for shaders with pre-defined per-channel macros like RESHADE_GBUFFER_NORMAL_AVAILABLE and similar. If material or scene describing buffers pack channels into single textures to reduce bandwidth (like R: Roughness, G: Metallic, B: Specular, A: Whatever) then I would say its the addon's responsibility to split that into individual resources which can be bound to the shader, or just in general pre-process the game-specific GBuffer into the conventional format for ReShade shaders.
// Consider each texture wrapped in #if RESHADE_GBUFFER_<channel>_AVAILABLE and has the associated sampler next to it
namespace GBuffer
{
    //// trivial buffer:
    
    texture AlbedoTex : RESHADE_GBUFFER_ALBEDO; // Linear color space preferably RGBA Float 16 but the main thing is that it can be HDR before tonemapping
    texture NormalTex : RESHADE_GBUFFER_NORMAL; // RGB for normal of course, A should be ignored
    
    //// non-trivial scene describing buffers
    
    // 2D screen-space velocity (pixel-space maybe?)
    texture VelocityTex : RESHADE_GBUFFER_VELOCITY; // RG Float 16
    
    // I've seen this method of packing the tangent space into a texture of quaternions (including normals) this can be useful for lighting or surface dependent effects
    texture TangentSpaceTex : RESHADE_GBUFFER_VELOCITY; // RGBA for tangent space quaternion
    
    // can be copy of the Stencil part of the Depth-Stencil, the goal is to have object isolation if available
    texture ObjectID : RESHADE_GBUFFER_OBJECTID; // uint8 maybe? or just INT on DX9?
    
    //// material buffers (assuming game does GGX or Disney/Principled lighting, otherwise I guess material features can be turned off)
    
    texture Emissive : RESHADE_GBUFFER_EMISSIVE; // RGB linear color
    texture RoughnessTex : RESHADE_GBUFFER_ROUGHNESS; // R8
    texture Metallic : RESHADE_GBUFFER_METALLIC; // R8
    // please propose more common material parameter channels like Glossy-layer, SSS or other 
}

And we could put other scene-describing parameters into convention like projection/view-camera matrices if they're available but maybe that's a simpler scenario. This is just brainstorming of course and I've just wanted to jump-start the conversation. I will try to make a GBuffer provider addon for UE4 games in my free time maybe based on these ideas we might discuss here.
Last edit: 2 years 2 months ago by microdee.
The following user(s) said Thank You: AlucardDH

Please Log in or Create an account to join the conversation.

  • Klaszlo5
More
2 years 2 months ago #2 by Klaszlo5 Replied by Klaszlo5 on topic Convention for GBuffer by add-ons
can we use this for smthg like the "Photorealistic Enhancement" or pix2pix, or only per object color corrections?

Please Log in or Create an account to join the conversation.

  • microdee
  • Topic Author
More
2 years 1 month ago #3 by microdee Replied by microdee on topic Convention for GBuffer by add-ons
yeaah I suppose where games use an object ID buffer or use a stencil buffer for object ID, but not many games use one I guess especially not older games, BUT even if that's available, you still won't know semantically what those ID's represent so GAN stuff will not work in a generic way I guess. Selective color correction is a given in scenario like this.
BUT
This is getting ahead of ourselves, I just proposed an idea, I haven't even started on that addon yet. :(

Please Log in or Create an account to join the conversation.

We use cookies
We use cookies on our website. Some of them are essential for the operation of the forum. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.