I am having a transparency issue with drawing multiple POINTS style PShapes into a P3D PGraphics object. Each Vertex inside the PShapes has its own image-driven alpha value. Vertices with partial transparency misbehave. Those in PShapes drawn later will properly blend partially into PShapes drawn earlier. The PShapes drawn earlier will still exhibit partial alpha transparency, but they will completely mask out (i.e. fully occlude) PShapes that were drawn later. In other words, it appears that PShapes drawn later only check for the existence of a potentially occluding pixel–they do not evaluate whether its alpha value is greater than 0.
I am a new user so it will only let me post one image at a time. Below is Image 1. See the followup post for Image 2.
Image 1 illustrates the desired behavior. Image 2 illustrators the incorrect behavior, with the circular image masking entirely through the face layer.
The only different is the order the PShapes were instantiated into PGraphics objects: Image 1 first added the red square, followed by the face, followed by the circular image. Image 2 added the red square, followed by the circular image, followed by the face.
This behavior is not acceptable for the purposes of this Sketch, because in some situations five separate PShapes will all have partial transparency information, in which case no PShape loading order would produce a correct result.
I have tried altering various hint() properties. None produce the correct result in situations where the order is “wrong.”
The script is too long to post in full, so there’s a pseudocode description of the process below. I will happily repost excerpts that might be useful for evaluating the problem, but I’m expecting the issue is more deeply rooted.
Pseudocode:
PGraphics canvas = createGraphics(width,height,P3D);
PShape s1,s2,s3;
s1,s2,s3 = createShape(POINTS); all vertices derived from image pixel values
canvas.shape(s1);
canvas.shape(s2);
canvas.shape(s3);
image(canvas,0,0);
It’s the order that I call the canvas.shape(xxx); commands that affects transparency performance.
One (not ideal) solution would be to load all images’ vertices into a single PShape, but this would not be ideal because I allow interactive repositioning of each image cloud, and resetting 2,000,000 vertices is much slower than translating a PShape.
Please let me know if there’s anything that can be done to resolve this. I am running Processing 3.5.4, Java mode, on a 2019 Macbook Pro. Thank you!