gpt4 book ai didi

Alpha/透明度和 MTKView?

转载 作者:行者123 更新时间:2023-12-04 12:20:18 24 4
gpt4 key购买 nike

我有一个 Metal 片段着色器,它返回一些带有 alpha channel 的透明颜色,我想在 MTKView 下显示一个 UIView,但我得到的背景结果只有黑色和“错误噪声”。

MTLRenderPipelineDescriptor:

pipelineStateDescriptor.isAlphaToCoverageEnabled = true
pipelineStateDescriptor.colorAttachments[0].pixelFormat = .bgra8Unorm
pipelineStateDescriptor.colorAttachments[0].isBlendingEnabled = true
pipelineStateDescriptor.colorAttachments[0].destinationRGBBlendFactor = .oneMinusSourceAlpha
pipelineStateDescriptor.colorAttachments[0].destinationAlphaBlendFactor = .oneMinusSourceAlpha

MTLRenderPass描述符:
renderPassDescriptor.colorAttachments[0].loadAction = .clear
renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColor(red: 0, green: 0, blue: 0, alpha: 0)

如果我更改清晰颜色,我可以在透明颜色下看到它,如果我跳过清晰颜色,我会看到“错误噪音”。清晰的颜色 alpha channel 实际上有什么作用吗?

有谁知道如何使 MTKView 透明?

更新:

这是使 MTKView 透明的神奇属性:
self.isOpaque = false

最佳答案

如果 UIView可能有透明的内容或者无法用不透明的绘图填充自己,那么它应该设置它的 opaque ( isOpaque ) 属性设置为 false 以便它将与后面的任何内容正确合成。从,MTKViewUIView 的子类,这也适用于它。

关于Alpha/透明度和 MTKView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47643974/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com