gl.readPixels alpha always return 255?


I want to read the pixel values from js-event…

const canvas = document.getElementsByTagName("canvas")[0]; = "canvas";
const gl = canvas.getContext("webgl");

let data = new Uint8Array(canvas.width * canvas.height * 4);
gl.readPixels(0, 0, canvas.width, canvas.height, gl.RGBA, gl.UNSIGNED_BYTE, data);

console.log(data) // rgb values return correct, but the alpha value always '255'

Is this a PIXI.js issue?


Is this an issue at all?
I mean, did you check with pixels that should return a lower value?


The canvas has no transparency so this seems normal.


Add a sprite in the game event and make the opacity 254 and so on.
Why can’t I get alpha if I read it in WebGL readPixels in that state?


This is working well in GDevelop. But your canvas is not transparent, it has a background color. This background color is not transparent, so alpha is 255.


I understand.

Can GDevelop make the background of the canvas transparent?
If GD can’t do that, change the game design.


For now I don’t think it’s possible.


Thank you for your answer!

But do you know the reason you can’t?
Is it a issue with the Gdevelop framework or PixiJS? Or HTML5 architecture?

I want to understand this situation for the my project.