Skip to content

Commit

Permalink
invoke function to set blend target (#7299)
Browse files Browse the repository at this point in the history
  • Loading branch information
minggo committed Sep 3, 2020
1 parent 9ffff43 commit acdcd87
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion cocos/core/gfx/pipeline-state.ts
Expand Up @@ -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;
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion cocos/core/renderer/core/pass.ts
Expand Up @@ -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; }
Expand Down

0 comments on commit acdcd87

Please sign in to comment.