mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
[iOS] fix additive, normal blending (#2822)
This commit is contained in:
parent
ae8c4792ba
commit
123426d3e3
@ -294,7 +294,8 @@ fileprivate extension BlendMode {
|
|||||||
case SPINE_BLEND_MODE_NORMAL:
|
case SPINE_BLEND_MODE_NORMAL:
|
||||||
return premultipliedAlpha ? .one : .sourceAlpha
|
return premultipliedAlpha ? .one : .sourceAlpha
|
||||||
case SPINE_BLEND_MODE_ADDITIVE:
|
case SPINE_BLEND_MODE_ADDITIVE:
|
||||||
return .sourceAlpha
|
// additvie only needs sourceAlpha multiply if it is not pma
|
||||||
|
return premultipliedAlpha ? .one : .sourceAlpha
|
||||||
case SPINE_BLEND_MODE_MULTIPLY:
|
case SPINE_BLEND_MODE_MULTIPLY:
|
||||||
return .destinationColor
|
return .destinationColor
|
||||||
case SPINE_BLEND_MODE_SCREEN:
|
case SPINE_BLEND_MODE_SCREEN:
|
||||||
@ -304,12 +305,13 @@ fileprivate extension BlendMode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func sourceAlphaBlendFactor(premultipliedAlpha: Bool) -> MTLBlendFactor {
|
var sourceAlphaBlendFactor: MTLBlendFactor {
|
||||||
|
// pma and non-pma has no-relation ship with alpha blending
|
||||||
switch self {
|
switch self {
|
||||||
case SPINE_BLEND_MODE_NORMAL:
|
case SPINE_BLEND_MODE_NORMAL:
|
||||||
return premultipliedAlpha ? .one : .sourceAlpha
|
return .one
|
||||||
case SPINE_BLEND_MODE_ADDITIVE:
|
case SPINE_BLEND_MODE_ADDITIVE:
|
||||||
return .sourceAlpha
|
return .one
|
||||||
case SPINE_BLEND_MODE_MULTIPLY:
|
case SPINE_BLEND_MODE_MULTIPLY:
|
||||||
return .oneMinusSourceAlpha
|
return .oneMinusSourceAlpha
|
||||||
case SPINE_BLEND_MODE_SCREEN:
|
case SPINE_BLEND_MODE_SCREEN:
|
||||||
@ -355,7 +357,7 @@ fileprivate extension MTLRenderPipelineColorAttachmentDescriptor {
|
|||||||
func apply(blendMode: BlendMode, with premultipliedAlpha: Bool) {
|
func apply(blendMode: BlendMode, with premultipliedAlpha: Bool) {
|
||||||
isBlendingEnabled = true
|
isBlendingEnabled = true
|
||||||
sourceRGBBlendFactor = blendMode.sourceRGBBlendFactor(premultipliedAlpha: premultipliedAlpha)
|
sourceRGBBlendFactor = blendMode.sourceRGBBlendFactor(premultipliedAlpha: premultipliedAlpha)
|
||||||
sourceAlphaBlendFactor = blendMode.sourceAlphaBlendFactor(premultipliedAlpha: premultipliedAlpha)
|
sourceAlphaBlendFactor = blendMode.sourceAlphaBlendFactor
|
||||||
destinationRGBBlendFactor = blendMode.destinationRGBBlendFactor
|
destinationRGBBlendFactor = blendMode.destinationRGBBlendFactor
|
||||||
destinationAlphaBlendFactor = blendMode.destinationAlphaBlendFactor
|
destinationAlphaBlendFactor = blendMode.destinationAlphaBlendFactor
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user