如何消除金属中的模糊纹理?

问题描述 投票:-3回答:1

我刚刚创建了一个Metal模板,并对代码进行了一点改动。我使用Minecraft 16x16青金石矿石纹理切换了默认的颜色图,但是由于某些原因,当它们的分辨率较低时,它们就会模糊掉。我总是希望它们像素化而不是模糊。

我该如何解决?有没有一种方法可以以不模糊的方式加载资产?这是负载资产函数:

class func loadTexture(device: MTLDevice, textureName: String) throws -> MTLTexture {
    /// Load texture data with optimal parameters for sampling
    return try MTKTextureLoader(device: device).newTexture(name: textureName, scaleFactor: 1.0, bundle: nil, options: [
        MTKTextureLoader.Option.textureUsage: NSNumber(value: MTLTextureUsage.shaderRead.rawValue),
        MTKTextureLoader.Option.textureStorageMode: NSNumber(value: MTLStorageMode.`private`.rawValue)
    ])
}

这里是模糊立方体的屏幕截图。如何使它不再模糊?我想要清晰的图像。

Blurry cube

swift textures metal
1个回答
0
投票
constexpr sampler textureSampler (mag_filter::nearest, min_filter::nearest); // Sample the texture to obtain a color const half4 colorSample = colorTexture.sample(textureSampler, in.textureCoordinate);
© www.soinside.com 2019 - 2024. All rights reserved.