Skip to content

Commit c459f8b

Browse files
csmartdaltoncsmartdaltonblakdragan7
committed
Switch image textures to premultiplied alpha
The renderer intentionally chose unmultiplied alpha for gradients, in order to not lose color information with transparent stops. But for this very same reason, we need *premultiplied* alpha for image textures. Otherwise, the (transparent) background color can bleed into edges. Switch image textures to premultiplied, while keeping gradients unmultiplied. Diffs= a70f0f84dd Switch image textures to premultiplied alpha (#9377) Co-authored-by: Chris Dalton <[email protected]> Co-authored-by: blakdragan7 <[email protected]>
1 parent 80d698b commit c459f8b

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

.rive_head

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9d516a9ece7c618a9ca4c861baefcd963497d2e0
1+
a70f0f84dda65ddd956b1229b9530aed37f44b18

wasm/src/bindings_webgl2.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ EM_JS(void, upload_image, (EMSCRIPTEN_WEBGL_CONTEXT_HANDLE gl, uintptr_t renderI
124124
return;
125125
}
126126
gl = GL.getContext(gl).GLctx;
127+
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
127128
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
129+
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
128130
});
129131

130132
EM_JS(void, delete_image, (uintptr_t renderImage), {

0 commit comments

Comments
 (0)