# Deferred rendering questions

This topic is 992 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am in the middle of Deferred renderer implementation.

So this is my global view on the renderer.

Correct me please if I am doing something wrong.

So the renderer consists of 5 parts:

1. Geometry pass: store normals, depth, color, specular, … into several GBuffer’s RT
2. For each light, use simple light-type shader (ambient, directional, point, spot, …) to calculate light and store it in to Light Accumulator RT.
3. Render this Accumulator RT into back buffer
4. Use forward renderer to render transparent meshes (2 passes: with front and back culling). Probably I will use only subset of lights on this stage.
5. Render some system objects like plate, origins, buttons, ...
CD3D11_RASTERIZER_DESC desc{ D3D11_DEFAULT };
desc.CullMode          = D3D11_CULL_FRONT;
desc.MultisampleEnable = TRUE;
desc.DepthClipEnable   = FALSE;

SetDebugName(m_transpRastStateFront.Get(), "Res::Transp.Front Rasterizer");

//Back cull mode rasterizer
desc.CullMode = D3D11_CULL_BACK;
SetDebugName(m_transpRastStateBack.Get(), "Res::Transp.Back Rasterizer");

1.  Is there a way to render directly into back buffer without light accumulator?

Right now if I use following blend state, but the final color is blended with background color.

With default blend state, only last color is rendered into backbuffer.

//Add current color to already in the Render Target (without alpha change)
D3D11_BLEND_DESC desc{ 0 };
desc.RenderTarget[0].BlendEnable    = TRUE;
desc.RenderTarget[0].SrcBlend       = D3D11_BLEND_ONE;
desc.RenderTarget[0].DestBlend      = D3D11_BLEND_ONE;
desc.RenderTarget[0].SrcBlendAlpha  = D3D11_BLEND_ZERO;
desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_RED | D3D11_COLOR_WRITE_ENABLE_GREEN | D3D11_COLOR_WRITE_ENABLE_BLUE;



2.  Adding some AA to final image.

As I know, antialiasing with GBuffer is not a trivial task.

So for first implementation, is it possible to use AA only in phase 4 (forward rendering) and in phase 5 (HUD rendering)?

Swap chain will create back buffers with multisampling, but GBuffer will be created with no AA.

Is it possible?

Will I have AA for transparent and HUD stages?

3.  2-pass rendering for transparent objects.

I read that 2-pass with different culling modes for transparent objects rendering is the only way (if I want to see light transformations from back side of an object).

When I tried on phase 4 use D3D11_CULL_NONE, some triangles were rendered with artifacts.

Is it my fault or this should be by default?

The only difference between images: 2 passes with D3D11_CULL_FRONT and D3D11_CULL_BACK vs 1 pass with D3D11_CULL_NONE.

[attachment=30126:2passes.jpg]  [attachment=30125:1pass.jpg]

Edited by Happy SDE

##### Share on other sites

For each light, use simple light-type shader (ambient, directional, point, spot, …) to calculate light and store it in to Light Accumulator RT.
Render this Accumulator RT into back buffer

If you're not using HDR lighting you can render directly into the back buffer.

I had a good web resource on deferred but don't remember it.  But I do remember this one from 2004.

edit - oh and as far as AA goes I think its been possible since DX10... I forgot the exactly how it works hopefully somebody will clarify but you can access specific subsamples within a render target so IIRC you can do a custom resolve.  If I have time I'll look it up its been a long time since I thought about it.

the only one I could find quickly was http://www.slideshare.net/TiagoAlexSousa/rendering-technologies-from-crysis-3-gdc-2013 starting on slide 41.

Edited by Infinisearch

##### Share on other sites
Regarding the AA, remember that you can always do AA as a post processing full screen effect, like with FXAA.

##### Share on other sites

BTW I think additive blending is correct for light accumulation, the back ground color should be black since black means no light.

##### Share on other sites
Infinisearch, on 03 Jan 2016 - 03:50 AM, said:Infinisearch, on 03 Jan 2016 - 03:50 AM, said:

BTW I think additive blending is correct for light accumulation, the back ground color should be black since black means no light.

So it seems for me that a light accumulation buffer is a way to go:

1. I would like to add HDR tone mapping support in the future (maybe some other post-processing)

2. I have not found yet a way how to remove background color and not to blend it with meshes color.

Edited by Happy SDE

1. 1
2. 2
Rutin
20
3. 3
4. 4
frob
15
5. 5

• 9
• 9
• 13
• 9
• 33
• ### Forum Statistics

• Total Topics
632592
• Total Posts
3007284

×