Fixed colors non premultiplied also in the editor.

This commit is contained in:
Davide Tantillo 2025-11-23 15:07:56 +01:00
parent c43d5154da
commit 86a0950a5f
2 changed files with 9 additions and 6 deletions

View File

@ -163,6 +163,7 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
private renderSkeleton (renderer: IRenderer, skeleton: Skeleton) {
let command = this.skeletonRenderer.render(skeleton);
const opacity = this.opacity;
const inv255 = 1 / 255;
while (command) {
const { numVertices, positions, uvs, colors, indices, numIndices, blendMode } = command;
@ -186,7 +187,7 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
const color = colors[i];
const colorDst = i * 4;
const alpha = (color >>> 24 & 0xFF) * inv255 * this.opacity;
const alpha = (color >>> 24 & 0xFF) * inv255 * opacity;
const alphaInverse = inv255 * alpha;
c3colors[colorDst] = (color >>> 16 & 0xFF) * alphaInverse;
c3colors[colorDst + 1] = (color >>> 8 & 0xFF) * alphaInverse;

View File

@ -118,7 +118,7 @@ class SpineC3PluginInstance extends SDK.IWorldInstanceBase {
skeleton.scaleY = _inst.GetPropertyValue(PLUGIN_CLASS.PROP_SKELETON_SCALE_Y) as number;
}
const opacity = _inst.GetOpacity();
const cos = Math.cos(offsetAngle);
const sin = Math.sin(offsetAngle);
const inv255 = 1 / 255;
@ -147,10 +147,12 @@ class SpineC3PluginInstance extends SDK.IWorldInstanceBase {
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;
const alpha = (color >>> 24 & 0xFF) * inv255 * 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;
}
iRenderer.ResetColor();