• Advertisement
Sign in to follow this  

How to sample a texture with 8 bit channel in shader?

This topic is 1664 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want a texture with 4 8bit channels so i define it as DXGI_FORMAT_R8G8B8A8_UINT. Is this the correct format i should be using? And how do i sample it in a shader because what i'm doing is not working:

 

float3 tID = Alphamap.Sample(Sampler, input.uv).rgb;

 

I'm assuming it's because floats are 32 bit, but i couldn't find an HLSL scalar type that's 8 bit...

Edited by Waaayoff

Share this post


Link to post
Share on other sites
Advertisement

Your code is absolutely correct. The sampling hardware converts the 4 * 8-bit texture into 4 * 32-bit float (or what is the float precision hardware is using). 

However, the texture format DXGI_FORMAT_R8G8B8A8_UINT isn't correct. the ending should  be _UNORM. 

 

Cheers!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement