2
\$\begingroup\$

I'm working on SAO (http://graphics.cs.williams.edu/papers/SAOHPG12/) and I want to store my ambient obscurance term (a value between 0.0 and 1.0) in a texture.

When I did shadowmapping, I created my depth-texture as DXGI_FORMAT_R32_TYPELESS and the shader resoure view as DXGI_FORMAT_R32_FLOAT, however with this I want a DXGI_FORMAT_R8_TYPELESS format and a FLOAT equivalent, yet there appears to be none according to the docs (http://msdn.microsoft.com/en-us/library/windows/desktop/bb173059(v=vs.85).aspx)

1) What texture/srv/rtv format should I use if I want to store/read/write 8-bit float values?

2) Does the format used really matter? Does directx do any behind-the-scenes alterations to the texture data? Is a DXGI_FORMAT_R8_UNORM treated differently from a DXGI_FORMAT_R8_SNORM for example?

\$\endgroup\$
  • \$\begingroup\$ 8-bit floats would have an extremely low precision. Are you sure you want an 8-bit float? DXGI_FORMAT_U8_UNORM is what you want if you do indeed need an 8-bit value (and yes, that's different than an SNORM, in that the former maps [0,256) to [0, 1.0] while the later maps [-128,+128) to [-1.0,+1.0]). \$\endgroup\$ – Sean Middleditch Sep 30 '14 at 22:31
  • \$\begingroup\$ for the purpose of storing a ambient obscurance term, perhaps R16 float is enough? \$\endgroup\$ – KaiserJohaan Oct 1 '14 at 8:28
1
\$\begingroup\$

The smallest single float supported by DirectX 11.x is DXGI_FORMAT_R16_FLOAT which requires Feature Level 10.0 or better hardware. The smallest single float supported by Feature Level 9.x is DXGI_FORMAT_R32_FLOAT.

If you can require Feature Level 10.0+ or better hardware, a better choice might be to use DXGI_FORMAT_R11G11B10_FLOAT or DXGI_FORMAT_R9G9B9E5_SHAREDEXP if you can live with the limitations of those formats.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.