Ch 14 - G-buffer

Hi all,

I have a question about the G-buffer. The concept of it is understood and I even got it to work on another project of mine. However, the book only covers one shader (excluding the composition), which creates the train in base color and its shadow. In my project I have a scene with multiple shaders. Some with base colors, others with textures, and some water reflection/refraction, each with their own render. There will be many more other renders later as well. But, for now lets say i have 3 renders that completes the scene.

How do I get the whole scene in one G-buffer? I was thinking about rendering a G-buffer for each render, so i end up with 3 G-buffers. Then before the composition stage i combine them somehow (if correct, how would be the best way to tackle this while preserving depth?), and the final accumulated G-buffer is then send to the composition shader. Am I in the right direction? I have a feeling im over-complicating this a bit. Please let me know. Thank you.

ps. As this is my first post: I want thank the whole team that made this book. This book has helped me a lot and even kickstarted an idea i had for years. Totally my money’s worth!

@mhorga Can you please help with this when you get a chance? Thank you - much appreciated! :]

@danielloriaux we’re happy you like the book :slightly_smiling_face:

the g-buffer is not about how many shaders you have but about what it consists of (various accumulation textures). as you can see in the book example, one texture is the albedoTexture and you can have as many shaders as you want contributing to the scene albedo (diffuse color). we also have various shaders (separate renders) for various objects in the scene but it is important that all objects write to the same albedoTexture for the scene’s complete color.

Hi @mhorga

Thank you for your quick reply and explanation. It’s clear to me now. Like i said, probably over thinking this, which i have a habit of doing. Thanks for the push in the right direction!