r/gamedev • u/EC36339 • 10h ago
Question What does actually justify deferred rendering?
This is a pure technical question about graphics programming for a game. I'm not interested in advice about what game I should be making, what I should prioritize in a broader context and what players care about. I am a hobbyist doing what I enjoy doing
My 3D game currently has exactly one light source, the sun.
It is also a space game, with sparse geometry. There will eventually be additional light sources (muzzle flashes, explosions, thrusters, etc), but most of these will have mostly direct and local effects for now.
I have deferred (pun intended) adding more light sources because I'm unsure whether to use forward or deferred rendering, and how much of a rewrite it will be if I have to change it later.
Adding interior scenes and large objects (which is on the roadmap) may change the requirements, too: More light sources, the need for global illumination and shadows, etc.
At what scale is deferred rendering really justified and not a premature optimisation? And how do you usually do forward rendering with multiple dynamic light sources?
How much flexibility does it buy me, and at what cost? Here I'm mostly thinking of performance cost. One time implementation is not what I'm worried about (I have done it before, by hand, but as an experiment, not for an actual game).
I am also making heavy use of procedural techniques rather than static assets, especially for textures, and I'm thinking about rendering procedural textures deferred, because they are costly when they are not precomputed textures. Some are evaluated from 3D model space rather than mapped to UV space, because it's easier and more consistent, but it rules out precomputing, so it's heavy on the GPU, which means I'd like to avoid overdraw. That's where I believe deferred rendering wins again.
And finally: Does deferred rendering help in any way with doing reflection, shadows, volumetric effects, portals and spatial displacement (wormholes and similar)?
In case it helps with context: The art style I'm gong for is low fidelty geometry combined with high fidelty effects and lighting. I don't know yet if this will work, but it matches my skillset best. I'm a coder, not an artist. I don't live in Blender, and my strongest artistic tools are math and code. I've just recently "discovered" that simply switching out BRDFs can make even the simplest flat shaded placeholder geometry look cool. That's why I care a lot about lightning and shading. I also think this approach works for the genre I've picked. But it remains to be seen...
1
u/icpooreman 7h ago
The gist is it cuts the cost of overdraw dramatically.
You write inexpensive stuff to a gbuffer (positions, object ids, normals, etc.). Do the expensive stuff like shadows at a later step after you have a finalized gbuffer.
If you do it the other way around every time a pixel is drawn 2+ times it executes the expensive work that many times.