金属:线性纹理过滤无法按预期工作 [英] Metal: linear texture filtering not working as expected

查看:98
本文介绍了金属:线性纹理过滤无法按预期工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm using Metal on iOS with the following fragment shader:

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图像.尽管过滤设置为线性,但我得到了以下图像,并进行了最近邻居过滤:

My texture is a 4x4 image. Despite the filtering set to linear, I get the following image, with nearest neighbor filtering:

看来我的uv很好,因为当我按如下方式修改片段着色器时:

It seems that my uv's are fine, since when I modify the fragment shader as follows:

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

我得到了预期的图像:

除了指定filter::linear以外,还需要做其他一些事情来使线性过滤工作吗?

Is there something else I need to do for linear filtering to work other than specify filter::linear?

推荐答案

在我的设备(iPad Pro)上,看来MTLPixelFormatRGBA32Float类型的纹理不支持线性过滤.当我更改为MTLPixelFormatRGBA8Unorm时,过滤将按预期进行.

It appears linear filtering isn't supported for textures of type MTLPixelFormatRGBA32Float on my device (iPad Pro). When I change to MTLPixelFormatRGBA8Unorm, filtering works as expected.

这篇关于金属:线性纹理过滤无法按预期工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆