从Depth32Float到Bgra8unorm施放mtltexture



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

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

我尝试使用: depthBufferTexture.makeTextureView(pixelFormat: .bgra8Unorm)进行转换:

有错误说:

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

有什么方法如何将depth32Float转换为bgra8UNorm或任何其他像素格式?

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

最新更新