I am trying to display a 2D overlay (head-up-display) over a 3D sketch using a shader. Now I have never created a shader before but have spent the last couple of days researching and experimenting.
I am very close in that I have a
- 3D animated sketch (p5js example)
- 2D overlay with transparent areas (created programmatically)
- shader program (based on code from GeeksForGeeks)
Now it all works except for one thing, although the 2D overlay has transparent areas they are appear opaque
Rather than post the code here I have created a test sketch on p5js web editor that you can copy and experiment with.
The last line in the draw() function is
displayHUD(canvas, hudBuffer);
If this is commented out then you see the 3D animation in action, but if executed it shows the HUD but the transparent areas are opaque. It is not replacing the 3D display as occasionally you get a glimpse of the purple balls in front of it.
Any help would be appreciated. ![]()
![]()