mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 15:24:55 +08:00
Fixed colors non premultiplied.
This commit is contained in:
parent
6a819315e0
commit
c43d5154da
@ -217,7 +217,6 @@ export class AssetLoader {
|
||||
|
||||
static async createImageBitmapFromBlob (blob: Blob, pma: boolean): Promise<ImageBitmap | null> {
|
||||
try {
|
||||
// pma parameters seems to do not matter here. It matters in C3 Texture creation
|
||||
return createImageBitmap(blob, { premultiplyAlpha: pma ? "none" : "premultiply" });
|
||||
} catch (e) {
|
||||
console.error("Failed to create ImageBitmap from blob:", e);
|
||||
|
||||
@ -184,13 +184,14 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
|
||||
vertices[dstIndex + 1] = y;
|
||||
vertices[dstIndex + 2] = 0;
|
||||
|
||||
// there's something wrong with the hand after adding the colors on spineboy portal animation
|
||||
const color = colors[i];
|
||||
const colorDst = i * 4;
|
||||
c3colors[colorDst] = (color >>> 16 & 0xFF) * inv255;
|
||||
c3colors[colorDst + 1] = (color >>> 8 & 0xFF) * inv255;
|
||||
c3colors[colorDst + 2] = (color & 0xFF) * inv255;
|
||||
c3colors[colorDst + 3] = (color >>> 24 & 0xFF) * inv255 * this.opacity;
|
||||
const alpha = (color >>> 24 & 0xFF) * inv255 * this.opacity;
|
||||
const alphaInverse = inv255 * alpha;
|
||||
c3colors[colorDst] = (color >>> 16 & 0xFF) * alphaInverse;
|
||||
c3colors[colorDst + 1] = (color >>> 8 & 0xFF) * alphaInverse;
|
||||
c3colors[colorDst + 2] = (color & 0xFF) * alphaInverse;
|
||||
c3colors[colorDst + 3] = alpha;
|
||||
}
|
||||
|
||||
renderer.setTexture(command.texture.texture);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user