2

I'm working with Direct3d 11, and I've come across something strange. I have taken a normal map and encoded it to a DDS file twice. Once with R8G8B8A8_SNORM encoding, and once with BC5_SNORM.

Next I load each texture using D3DX11CreateShaderResourceViewFromFile in conjunction with D3DX11GetImageInfoFromFile. When I sample these textures in my pixel shader I find that the R8G8B8A8_SNORM texture is returning values in the range [-1,1], which is what I would expect for a SNORM texture. However, the BC5_SNORM texture is returning values in the range [0,1], which doesn't make any sense to me.

I double an triple checked with my debugger and PIX. The format of the texture is correct (BC5_*S*NORM), so I am at a loss for why it's not returning signed values.

Chris_F
  • 4,991
  • 5
  • 33
  • 63
  • Are you certain the SSD file has been encoded correctly in the second case? – jcoder Mar 19 '12 at 15:11
  • @JohnB I don't know what you mean. I used **D3DX11CreateTextureFromFile** to load a PNG normal map as a BC5_SNORM texture and then I saved it to a DDS file with **D3DX11SaveTextureToFile**. I don't know what could possibly be wrong with that. – Chris_F Mar 19 '12 at 21:11
  • Ok it was just a thought that maybe it was converted wrongly – jcoder Mar 19 '12 at 21:30
  • Can you upload your dds files? – Vertexwahn Nov 14 '13 at 10:09
  • You may have more luck using [DirectXTex](http://go.microsoft.com/fwlink/?LinkId=248926) which is provided as shared-source, which would allow you to dig into the behavior more deeply. As noted, a sample .DDS would be most helpful. – Chuck Walbourn Jul 08 '14 at 18:50

1 Answers1

1

I managed to reproduce the same issue as you and I also got the same behaviour when doing a conversion from a R8G8B8A8_SNORM texture (with -1 to +1 values) to BC5_SNORM (producing only 0 to 1 values) when doing the conversion through D3Dx11LoadTextureFromTexture. There does appear to be a fault in D3DX11, at least regarding BC5_SNORM, in that, regardless of all kinds of input formats, the (BC5)SNORM output is always in the 0 to 1 range.

As suggested by @chuckwalbourn I can confirm that the DirectXTex utilities, which supersedes the now deprecated D3DX11, does respect and correctly handle signed values for BC5_SNORM outputs.

You can either have your program write out a temporary .dds (using D3DX11SaveTextureToFile with a R8G8B8A8_SNORM texture) and then invoke the standalone DirectXTex 'texconv.exe' utility to convert to BC5_SNORM, or wrangle the DirectXTex library into your program and use the 'Convert(...)' function appropriately.

Chuffleton
  • 26
  • 2