From acdcd87d00b5464fafd5a236532878c5980eda97 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 3 Sep 2020 20:03:26 +0800 Subject: [PATCH] invoke function to set blend target (#7299) --- cocos/core/gfx/pipeline-state.ts | 14 +++++++++++++- cocos/core/renderer/core/pass.ts | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/cocos/core/gfx/pipeline-state.ts b/cocos/core/gfx/pipeline-state.ts index fb7adb575ed..856829c6d03 100644 --- a/cocos/core/gfx/pipeline-state.ts +++ b/cocos/core/gfx/pipeline-state.ts @@ -138,7 +138,19 @@ export class GFXBlendState { public isA2C: boolean = false; public isIndepend: boolean = false; public blendColor: GFXColor = { r: 0, g: 0, b: 0, a: 0 }; - public targets: GFXBlendTarget[] = [new GFXBlendTarget()]; + public targets: GFXBlendTarget[] = [new GFXBlendTarget()] + + /** + * @en Should use this function to set target, or it will not work + * on native platforms, as native can not support this feature, + * such as `blendState[i] = target;`. + * + * @param index The index to set target. + * @param target The target to be set. + */ + public setTarget (index: number, target: GFXBlendTarget) { + this.targets[index] = target; + } } /** diff --git a/cocos/core/renderer/core/pass.ts b/cocos/core/renderer/core/pass.ts index 5f41ba23735..c4d0ac60bd7 100644 --- a/cocos/core/renderer/core/pass.ts +++ b/cocos/core/renderer/core/pass.ts @@ -140,7 +140,7 @@ export class Pass { const bsInfo = info.blendState; if (bsInfo.targets) { bsInfo.targets.forEach((t, i) => Object.assign( - bs.targets[i] || (bs.targets[i] = new GFXBlendTarget()), t)); + bs.targets[i] || (bs.setTarget(i, new GFXBlendTarget()), t))); } if (bsInfo.isA2C !== undefined) { bs.isA2C = bsInfo.isA2C; } if (bsInfo.isIndepend !== undefined) { bs.isIndepend = bsInfo.isIndepend; }