DX11 deffered render, position saving question

Started by
3 comments, last by MJP 12 years, 6 months ago
Hi all,

I am trying to implement deferred renderer using the description in a book, "Practical Rendering & Computation with Direct3D 11".

The description saves the world space position of the fragments into gbuffer. The problem I have is that the description does not say what DXGI format to use for positions.

Currently I use [font="Arial"]DXGI_FORMAT_R8G8B8A8_UNORM for albdeo and specular, and DXGI_FORMAT_R8G8B8A8_SNORM for[/font]
[font="Arial"]normalized world space normals[/font]
[font="Arial"]
[/font]
[font="Arial"]If I use SNORM for position, it will get clamped to -1,1 and this is exactly waht I don'd want.[/font]
[font="Arial"]
[/font]
[font="Arial"]What should I use in order to save my position?[/font]
[font="Arial"]
[/font]
[font="Arial"]Thx for any help[/font]
Advertisement
DXGI_FORMAT_R32G32B32_FLOAT or 16bit.

edit: there is no 16bit format for 3 components only DXGI_FORMAT_R16G16B16A16_FLOAT.[url=""][/url]


The alternative is that you reconstruct position from z-buffer (google).
Hey, I was the author of that chapter.

For the unoptimized version of the deferred renderer, I used a DXGI_FORMAT_R32G32B32A32_FLOAT texture for storing position. Obviously that's inefficient, but the whole point of that section was to do things the simplest way possible without regards for performance. You could also use DXGI_FORMAT_R16G16B16A16_FLOAT for position, but you are likely to encounter precision issues. The best way to do it is to reconstruct position from your depth buffer, which is described in detail in the optimizations section. But I would recommend getting it working with a position buffer first, and worry about optimizing it later.

BTW there's a sample that demonstrates the techniques in that chapter available on the Hieroglyph 3 site, if you ever need a reference.
Thx guys,

MJP I love the book, it is very well written and the diagrams really help since I am a more of a visual learner. Right now I am not too worried about performance until I get everything working.

I will take a look at Hieroglyph.

Btw I am using DX10 feature level, so I cannot have read-only depth buffer, does it mean I have to copy the buffer to read it even if I am using DX11 as API?

Thx guys,

MJP I love the book, it is very well written and the diagrams really help since I am a more of a visual learner. Right now I am not too worried about performance until I get everything working.


I'm glad you find it useful! If you ever have any questions you can feel free to PM me or ask here. I can also put you in touch with the other 2 authors if necessary.



Btw I am using DX10 feature level, so I cannot have read-only depth buffer, does it mean I have to copy the buffer to read it even if I am using DX11 as API?


Yeah unfortunately you can't read from the buffer and use it for depth testing at the same time, so you would need to copy it. Another option is to write out depth to another render target, and use that instead.

This topic is closed to new replies.

Advertisement