I have a texture with MTLPixelFormat.r32Float, and I would like to sample it with linear interpolation using texture.sample(mySampler, float2(u, v)). I am configuring the sampler as:
constexpr sampler mySampler (mag_filter::linear,
address::clamp_to_edge,
min_filter::linear);
However, within a metal Shader, texture.sample() always returns a 4-component vector (float4). So my questions are:
- Can the sampler interpolate the texture with MTLPixelFormat.r32Float correctly?
- If so, which component of the sampler output (float4) represents the sampled value?
So far, I have been unsuccessful at finding this out experimentally. None of the components of the sample output seem to work. Is it possible I have to configure sampling differently? Or is it impossible?