我想使用金属性能着色器从深度缓冲区处理信息,例如使用高斯或索贝尔着色器。
我将MTLTexture
与depth32Float
像素格式一起使用时会遇到问题。MPSImageGaussianBlur
或任何其他性能着色器不接受它作为源纹理。
我尝试使用: depthBufferTexture.makeTextureView(pixelFormat: .bgra8Unorm)
进行转换:
valyAteArguments forterfortextureviewondevice:1406:失败断言
source texture pixelFormat (MTLPixelFormatDepth32Float) not castable.
有什么方法如何将depth32Float
转换为bgra8UNorm
或任何其他像素格式?
从我看来,从 depth32Float
转换为 bgra8UNorm
是没有多大意义的,它们具有不同的维度和频道数量。在您的情况下,最好的解决方案是使用MTLPixelFormatR32Float
。要从depth32Float
转换为MTLPixelFormatR32Float
使用MTLComputeCommandEncoder
。