Skip to content

Commit 624903a

Browse files
committed
Fix issue with alpha blending
1 parent ccdca15 commit 624903a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/studio/formats/textures/GroupPhotoshopManager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ const combinePixel = (src: Uint8ClampedArray, dest: Uint8ClampedArray, srcIndex:
3838
const b2 = dest[destIndex + 2] / 255 * a2
3939

4040
//Blend the pixels together. The rgb values are premultipled above.
41-
const r = r1 + r2 * (1 - a1)
42-
const g = g1 + g2 * (1 - a1)
43-
const b = b1 + b2 * (1 - a1)
4441
const a = a1 + a2 * (1 - a1)
42+
const r = (r1 + r2 * (1 - a1)) / a
43+
const g = (g1 + g2 * (1 - a1)) / a
44+
const b = (b1 + b2 * (1 - a1)) / a
4545

4646
dest[destIndex] = Math.floor(r * 255)
4747
dest[destIndex + 1] = Math.floor(g * 255)

0 commit comments

Comments
 (0)