Skip to content

Commit 7274ed2

Browse files
committed
Do not let pixi modify texture pixel alphas...
1 parent b9e2ab4 commit 7274ed2

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

spine-ts/spine-pixi/example/darktint.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929

3030
document.body.appendChild(app.view);
3131

32-
// const orange = "-pma";
33-
const orange = "";
32+
const orange = "-pma";
33+
// const orange = "";
3434
PIXI.Assets.add("spineboyData", `./assets/orange${orange}.json`);
3535
PIXI.Assets.add("spineboyAtlas", `./assets/orange${orange}.atlas`);
3636
await PIXI.Assets.load(["spineboyData", "spineboyAtlas"]);

spine-ts/spine-pixi/src/assets/atlasLoader.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const spineTextureAtlasLoader: AssetExtension<RawAtlas | TextureAtlas, ISpineAtl
109109
page.setTexture(SpineTexture.from(providedPage));
110110
} else {
111111
const url: string = providedPage ?? utils.path.normalize([...basePath.split(utils.path.sep), pageName].join(utils.path.sep));
112-
const assetsToLoadIn = { src: url, data: { ...metadata.imageMetadata, ...{ alphaMode: page.pma ? ALPHA_MODES.PMA : ALPHA_MODES.UNPACK } } };
112+
const assetsToLoadIn = { src: url, data: { ...metadata.imageMetadata, ...{ alphaMode: ALPHA_MODES.NPM } } };
113113
const pixiPromise = loader.load<Texture>(assetsToLoadIn)
114114
.then((texture) => {
115115
page.setTexture(SpineTexture.from(texture.baseTexture));

spine-ts/spine-pixi/src/darkTintMesh/DarkTintRenderer.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void main(void){
7070
7171
7272
gl_FragColor.a = color.a * vColor.a;
73-
gl_FragColor.rgb = ((color.a - 1.0) * vDarkColor.a + 1.0 - color.rgb) * vDarkColor.rgb * gl_FragColor.a + color.rgb * vColor.rgb;
73+
gl_FragColor.rgb = ((color.a - 1.0) * vDarkColor.a + 1.0 - color.rgb) * vDarkColor.rgb + color.rgb * vColor.rgb;
7474
}
7575
`;
7676

@@ -96,9 +96,12 @@ export class DarkTintRenderer extends BatchRenderer {
9696
const vertexData = element.vertexData;
9797
const textureId = element._texture.baseTexture._batchLocation;
9898
const alpha = Math.min(element.worldAlpha, 1.0);
99-
const argb = Color.shared.setValue(element._tintRGB).toPremultiplied(alpha, (element._texture.baseTexture.alphaMode ?? 0) > 0);
99+
const alphaInt = Math.round(alpha * 255) & 0xFF;
100+
const tintRGB = element._tintRGB & 0xFFFFFF;
101+
const argb = (alphaInt << 24) | tintRGB;
100102
const darkargb = element._darkTintRGB;
101103

104+
102105
// lets not worry about tint! for now..
103106
for (let i = 0; i < vertexData.length; i += 2) {
104107
float32View[aIndex++] = vertexData[i];

0 commit comments

Comments
 (0)