Fixed colors non premultiplied.

This commit is contained in:
Davide Tantillo 2025-11-23 12:14:27 +01:00
parent 6a819315e0
commit c43d5154da
2 changed files with 6 additions and 6 deletions

View File

@ -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);

View File

@ -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);