Skip to main content
GameDev.net gamedev.net
🔒 Locked

Incorrect value range when sampling BC5_SNORM texture

Started by Chris_F Mar 15, 2012 at 5:09 PM 6 replies 2.2k views
Original Post
Chris_F
Chris_F
The problem I'm having is that when I load a R8G8B8A8_SNORM encoded dds texture and sample it in my shader, it gives me values in the [-1, 1] range as I would expect. But, If I load the same normal map that was encoded as BC5_SNORM and sample it, it gives me values in the [0, 1] range. blink.png

I'm using D3DX11CreateShaderResourceViewFromFile in conjunction with D3DX11GetImageInfoFromFile to load the textures. I doubled checked and the dds file in question is certainly BC5_SNORM and not BC5_UNORM.
Dawoodoz
Dawoodoz
I would use PIX and sample some pixels to see if the error is in loading of the texture or if the sampling don't know what format it is stored in.
Chris_F
Chris_F
I loaded it in pix. The first normal map shows as R8G8B8A8_SNORM and the second shows as BC5_SNORM. In my pixel shader the first returns [-1, 1] and the second [0, 1], such that:

Normal1.Sample(linearSampler, input.texcoord).xy

and

Normal2.Sample(linearSampler, input.texcoord).xy * 2 - 1

return the same value.
Dawoodoz
Dawoodoz
Could you find a pixel with negative values on the BC5_SNORM image in PIX?
Chris_F
Chris_F

Could you find a pixel with negative values on the BC5_SNORM image in PIX?


PIX is unable to display SNORM textures.
Dawoodoz
Dawoodoz
Then I would check Format in pLoadInfo given to D3DX11CreateShaderResourceViewFromFile.
Chris_F
Chris_F

Then I would check Format in pLoadInfo given to D3DX11CreateShaderResourceViewFromFile.


It's BC5_SNORM all day every day.
Chris_F
Chris_F
Bump.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.