mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
[ts][pixi] Fix parent alpha not working for dark tint. Aligned DarkTintMaterial shader with the Batcher one.
This commit is contained in:
parent
da8131e0e1
commit
64fe74e91c
@ -191,11 +191,9 @@ export class DarkTintMaterial extends Shader {
|
||||
public update(): void {
|
||||
if (this._colorDirty) {
|
||||
this._colorDirty = false;
|
||||
const baseTexture = this.texture.baseTexture;
|
||||
const applyToChannels = baseTexture.alphaMode as unknown as boolean;
|
||||
|
||||
Color.shared.setValue(this._tintColor).premultiply(this._alpha, applyToChannels).toArray(this.uniforms.uColor);
|
||||
Color.shared.setValue(this._darkTintColor).premultiply(this._alpha, applyToChannels).toArray(this.uniforms.uDarkColor);
|
||||
const missingAlphaInPMAColor = this._alpha / this._tintColor.alpha;
|
||||
Color.shared.setValue(this._tintColor).premultiply(missingAlphaInPMAColor, true).premultiply(this._alpha, false).toArray(this.uniforms.uColor);
|
||||
Color.shared.setValue(this._darkTintColor).premultiply(missingAlphaInPMAColor, true).premultiply(1, false).toArray(this.uniforms.uDarkColor);
|
||||
}
|
||||
if (this.uvMatrix.update()) {
|
||||
this.uniforms.uTextureMatrix = this.uvMatrix.mapCoord;
|
||||
|
||||
@ -43,6 +43,7 @@ export interface IDarkTintElement {
|
||||
_tintRGB: number;
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
_darkTintRGB: number;
|
||||
alpha: number;
|
||||
blendMode: BLEND_MODES;
|
||||
}
|
||||
|
||||
|
||||
@ -98,14 +98,10 @@ export class DarkTintRenderer extends BatchRenderer {
|
||||
const indicies = element.indices;
|
||||
const vertexData = element.vertexData;
|
||||
const textureId = element._texture.baseTexture._batchLocation;
|
||||
const alpha = Math.min(element.worldAlpha, 1.0);
|
||||
|
||||
const alphaInt = Math.round(alpha * 255) & 0xFF;
|
||||
const tintRGB = element._tintRGB & 0xFFFFFF;
|
||||
const argb = (alphaInt << 24) | tintRGB;
|
||||
|
||||
const darkTintRGB = element._darkTintRGB & 0xFFFFFF;
|
||||
const darkargb = (0xFF << 24) | darkTintRGB;
|
||||
const worldAlpha = Math.min(element.worldAlpha, 1.0);
|
||||
const missingAlphaInPMAColor = worldAlpha / element.alpha;
|
||||
const argb = Color.shared.setValue(element._tintRGB).premultiply(missingAlphaInPMAColor, true).toPremultiplied(worldAlpha, false);
|
||||
const darkargb = Color.shared.setValue(element._darkTintRGB).premultiply(missingAlphaInPMAColor, true).toPremultiplied(1, false);
|
||||
|
||||
// lets not worry about tint! for now..
|
||||
for (let i = 0; i < vertexData.length; i += 2) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user