Hi. I have a texture with format A8_UNORM. When i try to sample it in pixel shader it was returning just zero.But when i changed my shader variable from Texture2D<float> sth to Texture2D<float4> sth and in shader, sampled the alpha component instead of the red component (sth.Sample(...).a instead of sth.Sample(...).r) it worked well.I am really confused with this situation. Although my texture has single channel,i am able to sample it with Texture2d<float4>.Can someone please enlighten me?
The format dictates that that the data is in the alpha channel, not the red channel. So it makes sense that you have to ask for a float4 and use the alpha component, because if you asked for a single float you would get the red channel. You can always use R8_UNORM if you'd rather have the data in the red channel.