I'm a professional game developer from Wakefield, England, working as a senior programmer for Rebellion North.
I'm a married father of five and I a also sometimes do Retroburn stuff.
Martin 'Bytrix' Caine
Father. C++ Games Programmer. Cyclist. Guitarist.
emailfacebooktwittermessengersteamxboxliveretroburn
Tags
2013 3d alphalabs amazon apple archivirtual asynchronous battlefield bad company 2 ben 10 bepu beta blackmagic design blog blue marble bootcamp borderlands bsp calibration charity charvel childsplay comments competition content tracker counter-strike crash csgo css3 cycling dear esther deferred deus ex develop conference direct x discipline documentation doom 3 bfg dpi dr bott eidos elite force email deliverability eurogamer expo facebook focus fresnel game development game horizon game republic gamedev games gaming geoip girls make games global offensive grid guitar half-life 2 hawken hd7 hobbyist htc humble indie bundle imac indie indie trials indietrials intensity pro ip-countryside iron man 3 jamulus rift jquery kids kinect launch conference left 4 dead live lost mac mac osx manchester manhacks mass effect 2 matrox maya minecraft mirrors edge montreal morrowind movies museum of the microstar music mxo2 mini mysql nausea network networking nokia normal mapping obj oculus rift omnitrix ouya pedal for pounds php physics playstation suite port25 portal portal 2 positron posters powermta project aedra project euler promotion properties proton pulse ps vita ps4 psn racer reddit rendering retroburn game studios reviews rift racer riftracer roadkill roller coaster sdl2 shadow racers sharks shoct skyrifters snds space cadet spam trap star trek steam stencyl storage super stock sd1 fr superhot team fortress 2 tesselating tesselation texture editor thunderbird thunderclap ticktock games tiga track builder track bulder trials tv twitter uk ultimatrix usergroup vequencer video vireio visual assist visual studio vorpx voucher vr vr cinema war thunder warren web willow windows 8 windows 8.1 windows phone 7 workbench wp7 wp7dev xbla xblig xblig network xbox xbox live indie games xna xnaukug xperia play zombies on the holodeck
Archive
Links
Web
XNA
Games
Email Deliverability
Monday, February 21st 2011 / XNA

Deferred Rendering in XNA 4 - Introduction

I began writing my own deferred renderer in XNA about two years ago. There were a few excellent resources on ZiggyWare, Catalin Zima's site and Riemer Grootjan's site regarding deferred rendering. They helped me quickly get a working renderer written but I still didn't understand much of the maths and concepts behind it.. I just thought it looked cool.

Over the next few weeks I will be writing a series of articles detailing the way I use deferred rendering in my current projects and break it down step by step to not only help build understanding of how the renderer works but also show how to optimize various steps.

There are a number of ways you can create a deferred renderer but it usually entails creating a G buffer. This buffer is effectively a set of Render Targets which hold information on your scene (G for Geometry). You can then use the contents of these buffers to quickly and easily light your scene. It allows you to use potentially hundreds of lights with very little slow-down (note that performance on the Xbox 360 has to be monitored very carefully).

I'll run down the list of buffers I use in my renderer with a brief description of how they're used. In my next article I'll detail the process of creating the G buffer and writing to it.

Diffuse Buffer
The Diffuse Buffer stores the colour data for our scene. This is read from the various textures that make up each object in the scene.

Normal Buffer
The Normal Buffer stores the normal data for our scene. This is determined by the orientation of the vertices we are rendering but we also use additional detail from textures which contain normal data.

Depth Buffer
The Depth Buffer stores the depth data for our scene. Without hardware access to the Render Target's own depth buffer we have to store depth (as seen from the camera) in a Render Target which we can later access. Note the image above is a visualization of depth as seen from the camera.

Shadow Buffer
The Shadow Buffer stores the depth data as seen by a light. To properly determine which areas of the scene are in shadow we render the entire scene from the perspective of the light. Using this depth map we can test against our G Buffer to determine if an area is shadowed.

Shading Buffer
The Shading Buffer stores the shading data for our scene. For each light in our scene we can use the G Buffer to quickly determine how much each area of the scene is illuminated, we store this here and exclude areas that are shadowed. I love the look of the shading buffer and sometimes like to use it in the final output for various effects.

Combined Buffer
The Combined Buffer stores the combination of the other buffers. We use all of the information we've stored in the previous buffers to generate the final rendered scene here. This buffer can be displayed straight to the screen but in my renderer I have a number of Post Processing steps.

bloom Buffer
The final output of the scene. Here I have applied a simple bloom post process shader to the contents of the Combined Buffer. This enhances some of the brighter areas which exaggerates the lit areas. Other available post processing shaders I use are Depth of Field, Motion Blur, Hue Shift, Distortion and more.

The process of getting from our Diffuse Buffer to the final output is fairly complex especially when using multiple types of light and casting shadows. In the end though I think you'll agree it's worth it and our game renders pretty nicely. I look forward to writing the rest of this series and will include all the code to recreate each step as we go.

If you found this post helpful please leave a comment below:
 
Comments
Blam / 2011-10-27 01:06:47
Hey I was wondering if you were ever going to create/post your tutorials?
Martin Caine / 2011-10-27 20:13:49
Funny you should ask actually. I ran out of time and never managed to write up the tutorials but I have recently rewritten a chunk of my renderer so I'm in a good position to come back to this and get the series written in the next few weeks.
Mike / 2011-12-26 21:33:25
I know this is almost a year old, but would it be possible for a full length tutorial on this subject?

That screenshot looks amazing!
JBizzle / 2012-11-29 14:54:14
I would still be interested in the write up if you have the time. currently in school and trying to learn. cheers nice article.
Durli / 2012-12-11 15:56:52
Hey your result is very nice i want the tutorial please :-)
Tags:   deferred   rendering   shadow racers   xna
5