3

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.

Justin R.
  • 23,435
  • 23
  • 108
  • 157

1 Answers1

3

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;
Adam Miles
  • 3,504
  • 17
  • 15
  • The texture is declared as R32_FLOAT on the CPU side. On the GPU side, my texture is currently declared in the shader as "Texture2D texture". Is there something else I need to do to specify that it has only one channel? – Justin R. Jul 12 '13 at 22:41
  • Oh, I see what's happened here, StackOverflow's formatting removed two instances of ''. 'Texture2D texture; ' is what you want, I'll edit my answer. – Adam Miles Jul 12 '13 at 22:47