【问题标题】:Blend Mode in Metal金属中的混合模式
【发布时间】:2018-12-26 04:02:11
【问题描述】:

这是我在 OpenGL 中使用的两种混合模式,在 IOS 中转换为金属是什么

glEnable(GL_BLEND);

glBlendFuncSeparate(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA,GL_ONE,GL_ONE_MINUS_SRC_ALPHA);

glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_SRC_ALPHA, GL_ONE);

【问题讨论】:

    标签: swift metal metalkit


    【解决方案1】:

    您在渲染管道描述符上配置混合。我相信您的 GL 代码的等效配置是:

    // glEnable(GL_BLEND)
    renderPipelineDescriptor.colorAttachments[0].isBlendingEnabled = true
    
    // glBlendFuncSeparate(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA,GL_ONE,GL_ONE_MINUS_SRC_ALPHA)
    renderPipelineDescriptor.colorAttachments[0].sourceRGBBlendFactor = .sourceAlpha
    renderPipelineDescriptor.colorAttachments[0].destinationRGBBlendFactor = .oneMinusSourceAlpha
    renderPipelineDescriptor.colorAttachments[0].sourceAlphaBlendFactor = .one
    renderPipelineDescriptor.colorAttachments[0].destinationAlphaBlendFactor = .oneMinusSourceAlpha
    
    // glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_SRC_ALPHA, GL_ONE)
    renderPipelineDescriptor.colorAttachments[0].sourceRGBBlendFactor = .sourceAlpha
    renderPipelineDescriptor.colorAttachments[0].destinationRGBBlendFactor = .one
    renderPipelineDescriptor.colorAttachments[0].sourceAlphaBlendFactor = .sourceAlpha
    renderPipelineDescriptor.colorAttachments[0].destinationAlphaBlendFactor = .one
    

    【讨论】:

    • 第二个工作正常。但第一个即使我画了一个红色的四边形,我仍然得到清晰的屏幕
    猜你喜欢
    • 1970-01-01
    • 2019-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-08
    相关资源
    最近更新 更多