Deferred vs forward rendering

Forward lights objects as they are drawn; deferred records the surfaces first, then lights the finished image. Fewer lights favor forward.

which 3D lighting pipeline should I uselots of lights make my scene slowrender the lights after the objectswhy is transparency broken in deferred renderinghow do games handle a hundred lights at oncedeferred shadingdefered renderingg-buffer rendering

See it

Live demo coming soon

What it is

Forward rendering shades each visible fragment while its object is being drawn, using the lights that affect it. Deferred rendering splits that job in two: first it writes surface data such as color, normal, and depth into a set of textures called the G-buffer; then a later screen-space pass reads those textures and applies lighting.

Reach for deferred rendering when a scene has many dynamic lights. The geometry is recorded once, so adding another light does not require drawing every lit mesh again. Forward rendering stays attractive for small light counts, mobile bandwidth budgets, hardware anti-aliasing, and scenes with a lot of transparent material. Unreal Engine defaults to a deferred path, while Unity's Universal Render Pipeline defaults to forward for exactly those mobile reasons.

Gotcha: deferred rendering trades lighting work for memory traffic. A wide G-buffer can cost more than it saves at high resolution, and ordinary alpha blending cannot be deferred because the G-buffer keeps one surface per pixel. Transparent objects normally need a separate forward pass after the deferred lighting pass.

Ask AI for it

Build switchable forward and deferred lighting paths in WebGL2. For the deferred path, create a framebuffer with color, encoded normal plus roughness, and material textures, attach a depth texture, and enable the attachments with WebGL2RenderingContext.drawBuffers(). Render opaque geometry into that G-buffer, reconstruct view-space position from depth in a full-screen lighting pass, and accumulate 64 moving point lights. Render alpha-blended objects afterward with the forward path. Add a debug toggle that displays each G-buffer attachment and a timing readout for both pipelines.

You might have meant

transparency sortingdraw calloverdrawdepth buffer z bufferpost processing render pass