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.

4

1 回答 1

3

要么声明你的纹理有一个通道,要么指定你想要的通道。如果没有这个<float>位,它将假定它是一个 4 通道纹理,因此 Sample 将返回一个 float4。

Texture2D<float> texture;

或者

float sample = texture.Sample(sampler, coordinates).r;
于 2013-07-12T22:29:09.847 回答