1

我想使用金属性能着色器处理来自深度缓冲区的信息,例如使用高斯或索贝尔着色器。

MTLTexture使用depth32Float像素格式时遇到问题。MPSImageGaussianBlur或任何其他性能着色器不接受它作为源纹理。

我尝试使用转换它:depthBufferTexture.makeTextureView(pixelFormat: .bgra8Unorm)但收到错误消息:

validateArgumentsForTextureViewOnDevice:1406:断言失败source texture pixelFormat (MTLPixelFormatDepth32Float) not castable.

有什么方法可以转换depth32Floatbgra8UNorm或任何其他像素格式吗?

4

1 回答 1

2

在我看来,从 转换depth32Floatbgra8UNorm没有多大意义,它们具有不同的维度和通道数量。在您的情况下,最好的解决方案是使用MTLPixelFormatR32Float. 转换depth32FloatMTLPixelFormatR32Float使用MTLComputeCommandEncoder.

于 2019-02-15T16:51:50.853 回答