3
votes

I have a 2D texture formatted as DXGI_FORMAT_R32_FLOAT. In my pixel shader I sample from it thusly:

float sample = texture.Sample(sampler, coordinates);

This results in the following compiler warning:

warning X3206: implicit truncation of vector type

I'm confused by this. Shouldn't Sample return a single channel, and therefore a scalar value, as opposed to a vector?

I'm using shader model 4 level 9_1.

1

1 Answers

3
votes

Either declare your texture as having one channel, or specify which channel you want. Without the <float> bit, it'll assume it's a 4 channel texture and so therefore Sample will return a float4.

Texture2D<float> texture;

or

float sample = texture.Sample(sampler, coordinates).r;