Sign in to follow this  
Followers 0
Waaayoff

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

3 posts in this topic

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
0

Share this post


Link to post
Share on other sites

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!

1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0