Let there be light!

I’ve spent the last day or two recoding the renderer for my engine from scratch and it was worth it! I’ve managed to increase performance by an insane amount compared to the previous renderer and on top of that, the new one is capable of normal mapping ,specular mapping and point lighting. The biggest change between both renderers was the addition of deferred rendering, which allows several effects to be applied over the original scene without much of a performance hit for each one. This is one of the main reasons the new renderer is capable of rendering a large number of lights and still maintaining 60+ fps. Obviously performance won’t be the same on lower end machines but its a start! 🙂

The scene below contains 100 cubes and 50 lights (and a decent frame rate!):

100 cubes and 50 lights screenshot
Click for larger image


If your wondering what the small views or windows are overlapping the big one, they’re the different render-targets that are used to make up the final image you see on the screen.  Currently there are 4 render-targets:

  • Scene Render Target (RT) – This is where the raw scene gets rendered to before any effects are applied over it
  • Normals – Mainly used for lighting and shadow effects. Each objects normals (and there normal maps) are added to this RT.
  • Depth – This can be used for a lot of things, such as soft shadows, fog, depth of field and lighting (again). The further away an object is the more “whiter” it shows up in this RT.
  • Light Map – All visible lights are rendered to this RT. What you’ll see in this RT is how the lights look before they’re applied over the original scene.

I previously mentioned that I increased performance a lot on the new renderer. Well, it turns out its around 18x faster and mostly because of a simple change. When calculating the world matrix for every instance of an object, I previously looped through the instance “position” dictionary to update them in the instance “position” array. On the new renderer, I just convert all of the positions in the instance dictionary into an array using the dictionaryName.Values.ToArray(); method.

I still need to add a new post-processing system to the renderer and re-add the particle system so it makes use of hardware model instancing this time, but thats all for now. I’ll leave you with a lame scene full of 89,000 cubes and 20 lights (not bad FPS considering there is no culling system yet). 🙂

Insane scene

Click for larger image