Closed harshkhandeparkar closed 3 years ago
So the buffer gets the correct RGB (1, 0, 1) but it shouldn't be the final color due to the 0 alpha. I wonder if frame buffers actually hold data like this in WebGL. I haven't gotten that close to the metal of the spec to be honest. Is it possible that it held that as the clear color and the alpha produced what WebGL thought was "clear?"
Also, does this have any effect on something you're developing? Just curious. I'm not likely to be the one who fixes this, but it's good to know limitations of necessary evils when running calculations.
Well, the gpu.js API supports alpha and WebGL probably does, too. If it isn't supported, why is it even there? It doesn't really concern what I am developing, I was just experimenting with alpha values to see if I can make interpolation smoother. Now I have realized that changing the alpha will do nothing :joy:
I'm not saying that it doesn't support it. I'm just thinking out loud that when gpu.js gets a frame that finalizes to be 100% clear, it may use the previously computed color as the "clear" value so it doesn't have to write new data to the buffer. I'm not sure if that's how it's operating or if that's part of the spec. Does 100% opaque color still get written out if a partial alpha is used, like 0.1 or 0.5?
@robertleeplummerjr Can you offer any insight here?
Yes, partial alpha also gives opaque colors.
Does this behavior change at all when you force premultiplied alpha for the GPU's context? Something like this:
const canvas = DOM.canvas(500, 500);
const gl = canvas.getContext('webgl2', { premultipliedAlpha: false });
const gpu = new GPU({
canvas,
context: gl
});
... where you'd want to specify premultipliedAlpha
. This snippet was hiding in the readme, by the way, I didn't write it. If that doesn't do it, be prepared to crack open the fragment shader code. It'll have to be something in there.
Hmm. GLSL is headache...
My local dev env is filled with many other changes so I can't even test this rn.
Yes, premultiplied alpha is working. 1) That needs better documentation 2) It is still quite difficult to use
But I don't really need alpha anymore ¯\_(ツ)_/¯
Yeah, I agree with both points. Seems fine if you already know it, I'm sure, but sometimes you won't know unless you try it... The more of a pain it is to try something new, the fewer people will attempt it. It feels like this could be abstracted to a cleaner solution.
What is wrong?
This kernel should ideally display nothing since the alpha is 0, but it displays this:
Where does it happen?
I was trying to change something in gpujs-real-renderer
How do we replicate the issue?
How important is this (1-5)?
5.5555555555.......
Expected behavior (i.e. solution)
Other Comments