DirectX11 and Deferred rendering

Started by
38 comments, last by Zwingling 13 years ago
I don't mean to create yet ANOTHER basic Deferred Rendering thread, but after searching this forum (and google) I felt it was necessary.

I am looking for a tutorial that would walk me step through step of how to set up a deferred render using DirectX11. I have written a forward renderer in DirectX9 (I used DirectX9 for about four years) and have been using DirectX11 for several months. I have seen a few code samples for a Deferred Renderer in DirectX11, however, nothing that really shows me step by step of how to set one up (I have of course done basic rendering and render to texture already).

If there is something that shows a step by guide for DirectX10, I would of course follow that, but if there is, could someone please tell me what improvements DirectX11 has given in the context of Deferred Rendering over DirectX10?
Advertisement
Check out http://humus.name/index.php?page=3D&ID=81

Be carefull thought, all of his code uses column major matrix' for directx.
Wisdom is knowing when to shut up, so try it.
--Game Development http://nolimitsdesigns.com: Reliable UDP library, Threading library, Math Library, UI Library. Take a look, its all free.
This is one of the resources I have found in my research, however, he does have his code in DirectX10.1, which is fine (if there is nothing in DirectX11 out there with a tutorial) and he does not any tutorial on how he set everything up (at least, from what I saw).
Couldn't you follow a tutorial which outlines the concept in DirectX9, then apply what you've learnt to DirectX11?

That's what I did. Works a treat. Also, updating all the code to work with DirectX11 ensured I knew exactly what was going on, rather than simply copy and pasting. You should find areas that can be optimized also, as most tutorials are designed to be understood rather than written for performance.

If you understand the concept of deferred shading, you should be able to implement it using just the msdn.

Saving the world, one semi-colon at a time.

Well, the code difference between directx 10 and 11 is very very small. The only difference is you have function calls with an 11, instead of a 10. If you get the directx 10 version working, then just convert it to 11. Should take like.... 30 minutes to do the conversion. But, do not convert before you even get the directx 10 version working --thats asking for compounded problems.


Wisdom is knowing when to shut up, so try it.
--Game Development http://nolimitsdesigns.com: Reliable UDP library, Threading library, Math Library, UI Library. Take a look, its all free.
Quote:Original post by simotix
If there is something that shows a step by guide for DirectX10, I would of course follow that, but if there is, could someone please tell me what improvements DirectX11 has given in the context of Deferred Rendering over DirectX10?


Off the top of my head...

1. You can create "read-only" depth stencil views. This is useful if you sample the depth buffer directly for reconstructing position. In D3D10, you couldn't have a depth stencil buffer bound for depth testing AND sample it as a shader resource view simultaneously. Now you can do it if you create a read-only view, and make sure that depth/stencil writes are disabled.

2. This is actually a 10.1 feature, but still useful in 11: you can run pixel shaders at per-sample frequency. Handy for enabling MSAA with a light prepass/deferred lighting setup, since you need to calculate and store lighting at sample resolution.

3. You can take SV_Coverage as an input for the pixel shader. This lets you avoid shading subsamples where the depth/stencil or coverage test failed when MSAA is enabled. Otherwise you would have to run the shader at per-sample frequency. SV_Coverage also gives you a more direct way of detecting edge pixels, rather than using the centroid sampling trick demonstrated in one Humus's samples.

4. Another 10.1 feature: you can sample MSAA depth buffers.

5. You can use compute shaders to perform your lighting on a fixed grid. This is the fastest way to shade many (hundreds) of lights. See this sample.

Quote:Original post by Pthalicus
Couldn't you follow a tutorial which outlines the concept in DirectX9, then apply what you've learnt to DirectX11?


I figured that the benefits from DirectX9 to DirectX11 were so much that it would not matter much to follow a DirectX9 tutorial. Is there any great DirectX9 tutorials for setting up a deferred renderer?

Quote:Original post by smasherprog
Well, the code difference between directx 10 and 11 is very very small. The only difference is you have function calls with an 11, instead of a 10. If you get the directx 10 version working, then just convert it to 11. Should take like.... 30 minutes to do the conversion. But, do not convert before you even get the directx 10 version working --thats asking for compounded problems.



The problem is that I do not have a DirectX10 renderer written, which I could do given some extra time though.
I am still trying to collect difference resources and code on implementing deferred rendering in DirectX11 (or DirectX10). So far I have found two resources for code, the one by humus (although I can not compile it as all the framework code is not available and the one provided by intel (which uses compute shaders). I have seen and been reading several articles on the concept, such as the G-Buffer, but there is several concepts that I feel would be worth seeing done in practice so I may learn more about it. Does anyone have any other available code samples that implement deferred shading? I would rather it be something directly related to a code base made for deferred shading, rather then some larger engine I am trying to rip through to understand.
http://www.catalinzima.com/tutorials/deferred-rendering-in-xna/

Check it out. It's in C#/XNA which I've never used before (shaders are in HLSL), but I could easily port it to Directx9 and later Directx10.
From reading that and much of the other sources I have found on Deferred Rendering, I am now trying to piece together a Deferred Rendering solution DirectX11. Unfortunately this is going to cause a lot of questions as I have not found anything native to the DirectX11 or DirectX10 API.

The first part I am having an issue with is the creation of a render targets. From what I see, I will need five render targets.

1) Depth render target in D24S8 format
2) Normal/Specular render target in A8R8G8B8 format
3) Diffuse render target in a X8R8G8B8 format
4) Specular render target in a X8R8G8B8 format
5) Emisive to a X8R8G8B8 format (I currently do not use emmisive anywhere, so I may ditch this).

While I was able to translate the depth render target, I am unsure of what "A8R8G8B8" is in DirectX11. From what I can tell there is a "DXGI_FORMAT_R16G16B16A16_FLOAT" which seems like it would be too large for what is needed, and a "DXGI_FORMAT_R8G8B8A8_TYPELESS". It seems as if "DXGI_FORMAT_R8G8B8A8_TYPELESS" is the closest to this and I will need to resolve the type somehow.

D24S8 = DXGI_FORMAT_D24_UNORM_S8_UINT

Are these the correct render target types?

This topic is closed to new replies.

Advertisement