gpt4 book ai didi

ios - Metal :线性纹理过滤未按预期工作

转载 作者:可可西里 更新时间:2023-11-01 05:40:16 25 4
gpt4 key购买 nike

我在 iOS 上使用带有以下片段着色器的 Metal:

constexpr sampler s(coord::normalized,
address::clamp_to_zero,
filter::linear);

fragment half4 passThroughFragment(VertexInOut inFrag [[stage_in]],
texture2d<float> tex [[ texture(0) ]])
{
return half4(tex.sample(s, inFrag.uv));
}

我的纹理是 4x4 图像。尽管过滤设置为线性,但我得到以下图像,使用最近邻过滤:

Image with nearest neighbor filtering

看来我的 uv 没问题,因为当我如下修改片段着色器时:

return half4(0, inFrag.uv.x, inFrag.uv.y, 1);

我得到了预期的图像:

Plot of UV coordinates

除了指定 filter::linear 之外,我还需要做些什么来使线性过滤工作吗?

最佳答案

在我的设备 (iPad Pro) 上,MTLPixelFormatRGBA32Float 类型的纹理似乎不支持线性过滤。当我更改为 MTLPixelFormatRGBA8Unorm 时,过滤会按预期工作。

关于ios - Metal :线性纹理过滤未按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40811454/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com