Metal MTLTexture replaces semi-transparent areas with black when alpha values that aren't 1 or 0

后端 未结 2 621
一生所求
一生所求 2020-12-18 22:06

While using Apple\'s texture importer, or my own, a white soft-edged circle drawn in software (with a transparent bg) or in Photoshop (saved as a PNG) when rendered will hav

2条回答
  •  隐瞒了意图╮
    2020-12-18 22:42

    Thanks to Jessy I decided to look through how I was blending my alphas and I've figured it out. My texture still looks darkened in the GPU debugger, but in the actual app everything looks correct. I made my changes to my pipeline state descriptor, which you can see below.

    pipelineStateDescriptor.colorAttachments[0].blendingEnabled = true
    pipelineStateDescriptor.colorAttachments[0].rgbBlendOperation = .Add
    pipelineStateDescriptor.colorAttachments[0].alphaBlendOperation = .Add
    pipelineStateDescriptor.colorAttachments[0].sourceRGBBlendFactor = .DestinationAlpha
    pipelineStateDescriptor.colorAttachments[0].sourceAlphaBlendFactor = .DestinationAlpha
    pipelineStateDescriptor.colorAttachments[0].destinationRGBBlendFactor = .OneMinusSourceAlpha
    pipelineStateDescriptor.colorAttachments[0].destinationAlphaBlendFactor = .OneMinusBlendAlpha
    

提交回复
热议问题