Again, a long time has passed since the last news and again we have many things to show you! So much, that we have to split it up into at least four news. The first thing we want to show to you is the new Deferred Shading in [w]tech. I bet, some of you know this technique, some heard about it and the others don't know what I'm talking about.
Lets start with a screenshot of the result:
You see, Deferred Shading is a lighting technique. Many engines and games use it today, just because it is able to create high performance, per-pixel and dynamic lighting. The best way to explain you how it works is to go through each step of the process. We use a simple scene as example:
Here, we have the unlit diffuse color of the rendered scene:
This are the normals, either per face or with a normal map on top, of all meshes in the scene. Normals are vectors pointing into the direction of each face:
And last but not least we need the depth of the scene:
These three shots are the minimal information you need to create lighting via Deferred Shading. Later, we'll add more of them, to get stuff like specular reflections or emissive color working.
So, what is to do with this different types of the scene? We need to render a quad all over the screen for each light. Then we can calculate the right values in the PixelShader, for each rendered pixel. For instance, the depth, isn't needed as depth, but as a source to calculate the world space pixel positions, to apply the light at the right location.
Now, with the diffuse color, the normals, and the vertex position in world space, we can let run everything through a formula, add the result to the BackBuffer, your screen, and here is our lighting!