BryanMcPhail.com

Professional software development, amateur BMW tinkering, old arcade game stuff

By

Deferred lighting mixed with forward rendering

I happened to find this random image on my hard drive and thought it may be worth a post. It shows using deferring lighting on top of a prelit forwarded rendered scene.

deferred

Now, this is not a discussion about whether deferred lighting or forwarding rendering is best! That choice depends on a lot of things, particularly how your artists can generate the best art, and the style of the game. In this case, the game had already been created with a forward render in mind, and all landscape art was prelit with static generated shadows, etc. The only dynamic lights required for the game were explosions. One solution is to have shader variants such that all of the prelit shaders can accept a light and render them in the usual order (opaque, alpha test, transparent, etc). The alternate solution shown here is deferred post-fx lighting on top of the prelit scene by using additive blend just to ‘add’ onto what is already there. It’s not mathematically correct, but it’s fast and good enough for fast moving lights like explosions!

Unlike full deferred lighting, this hack doesn’t need an albedo buffer so it can be quick to add into an existing forward setup. You still need the depth buffer, but it’s probably around anyway for use in soft particles, or other effects. You also need the normal buffer which on PS3 and PC was generated via multiple render targets in the one pass, but on Xbox 360 and WiiU it was generated at half size in a unique render pass for performance.

So with depth buffer & normal buffer the shader can reconstruct a world space point & normal for each pixel on screen and use that to add light as a post-process.

Leave a Reply