我刚刚创建了一个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)
])
}
这里是模糊立方体的屏幕截图。如何使它不再模糊?我想要清晰的图像。
constexpr sampler textureSampler (mag_filter::nearest,
min_filter::nearest);
// Sample the texture to obtain a color
const half4 colorSample = colorTexture.sample(textureSampler, in.textureCoordinate);