Deferred rendering questions

Started by
3 comments, last by Happy SDE 8 years, 3 months ago

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;

_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;
desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_RED | D3D11_COLOR_WRITE_ENABLE_GREEN | D3D11_COLOR_WRITE_ENABLE_BLUE;

_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]

Advertisement


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.

http://http.download.nvidia.com/developer/presentations/2004/6800_Leagues/6800_Leagues_Deferred_Shading.pdf

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.

-potential energy is easily made kinetic-

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

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

-potential energy is easily made kinetic-

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.

This topic is closed to new replies.

Advertisement