In p5.js (v1.9.0) I am trying to setup a very basic shader, setting the alpha channel of some shapes to see transparency (overlapping shapes should appear brighter). The whole code is visible here:
https://editor.p5js.org/evilmandarine/sketches/WdqoaeEr7
This uses version 1.9.0 and there is no transparency at all. It looks like alpha channel was set to false by default in version 1.4.1. In this example using version 1.4.0 alpha channel works, however last drawn shape is above first one; I would expect to see a bit of the bottom shape as there is some level of transparency:
https://editor.p5js.org/Kumu-Paul/sketches/9RMzCJwMX
I have the feeling I am mixing up p5 canvas alpha/blending mode with WebGL/shader blending mode.
Question is how to enable transparency in version 1.9.0 and also how to set the blend mode?
In my example, how to show a result similar to this one but using the shader?
Alpha channel works as is with p5.js 1.9.0. Here's an example:
There are a few nuanced behaviors evidenced here:
The moral of the story here is that if you want to use alpha with p5.js WebGL then you need to manage your own triangles and control the order in which they are drawn (furthest from the camera to nearest, possibly skipping triangles facing away from the camera).