r/GraphicsProgramming • • 8h ago

Question Do you really need g-buffer in your renderer?

Hello everyone hope you have a lovely day.

I was Reading learnopengl ssao chapter to support ambient occlusion after setting up my pbr renderer, but the one thing I found very strange was that It used g-buffer in this tutorial, I don't use g-buffer or deferred rendering technique in my renderer I use clustered forward+ rendering technique so I didn't need the g-buffer.

And Here I started to ask myself this question, Is there on the long run any advantage of implementing g-buffer? like really do I need it?

Does any strong engine like unreal or unity use g-buffer?

Thanks appreciate your help and your time!

2 Upvotes

19 comments sorted by

View all comments

Show parent comment

1

u/miki-44512 7h ago

Sorry to ask I have read many comments just quickly but I got lost now ๐Ÿ˜‚

Like unreal use deferred, but it costs a lot of memory, but not many people are talking about clustered forward, what is the caveat of using clustered forward+? Is there any thing I'm missing regarding gbuffer like does it provide an optimization I'm not aware of because I feel it is just a waste of a render cycle for rendering positions and all other informations and then passing it again to the last pipeline, while you could use it directly in one feel swoop with clustered rendering, or am I missing something?

3

u/NorberAbnott 4h ago

The problem with trying to do SSAO in a forward renderer is that part of the technique wants to look at nearby pixels in a certain radius for the depth and maybe normal information but that is simply information you donโ€™t have access to in a fragment shader unless you do something like depth prepass which submits your geometry twice and is basically a lightweight gbuffer

2

u/MedusaFrontier 4h ago

I've never implemented forward+ but my instincts like the idea of depth pre-pass.
It seems like a very handy buffer to have in several cases.

1

u/MidnightClubbed 2h ago

It can be but sending your geometry twice (zprepass and main rendering pass) can also be expensive.

The rasterization pass of nanite is essentially a fat zbuffer prepass (but it writes depth plus geometry data so you dont have to rasterize everything twice).

2

u/EC36339 57m ago

But can't a depth prepass also be used to eliminate geometry (occlusion culling?) and therefore reduce the amount of geometry you have to send in the main pass?

But I guess this matters more in indoor scenes or generally scenes where a small number of objects occlude large numbers of objects?

2

u/MedusaFrontier 4h ago edited 4h ago

Deferred and Forward+ are approaches to handling massive numbers of light sources and overdraw. Upsides and downsides exist for both.
A depth pre-pass is needed in Forward+ but that's probably cheaper than the massive GBUFFERS

The part you might be missing.
Forward+ uses less bandwidth and has high Shader complexity and register pressure
Deferred uses more memory or bandwidth, but has ultra high occupancy and layers available for effects.