Metal: linear texture filtering not working as expected

家住魔仙堡 提交于 2020-05-25 03:09:27

问题


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));
}

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

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);

I get the expected image:

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


回答1:


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.



来源:https://stackoverflow.com/questions/40811454/metal-linear-texture-filtering-not-working-as-expected

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!