Jump to content
  • Advertisement
Sign in to follow this  
Happy SDE

Deferred rendering questions

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

If you intended to correct an error in the post then please contact us.

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, ...
desc.CullMode          = D3D11_CULL_FRONT;
desc.MultisampleEnable = TRUE;
desc.DepthClipEnable   = FALSE;

_check_hr(m_device->CreateRasterizerState(&desc, m_transpRastStateFront.GetAddressOf()));
SetDebugName(m_transpRastStateFront.Get(), "Res::Transp.Front Rasterizer");

//Back cull mode rasterizer
desc.CullMode = D3D11_CULL_BACK;
_check_hr(m_device->CreateRasterizerState(&desc, m_transpRastStateBack.GetAddressOf()));
SetDebugName(m_transpRastStateBack.Get(), "Res::Transp.Back Rasterizer");


Here are 3 additional questions:


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].BlendOp        = D3D11_BLEND_OP_ADD;
desc.RenderTarget[0].SrcBlendAlpha  = D3D11_BLEND_ZERO;
desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
desc.RenderTarget[0].BlendOpAlpha   = D3D11_BLEND_OP_ADD;

_check_hr(MGL::DevicePtr()->CreateBlendState(&desc, m_omBlendState.GetAddressOf()));
MGL::SetDebugName(m_omBlendState.Get(), "Additive light merge");


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 this post

Link to post
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 this post

Link to post
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

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!