As you can see, sometimes it works great (the point is transparent) and sometimes it seems that the point is opaque (i.e. we can’t see the other one that’s behind it).
Any idea how I can fix this?
Also, any idea how I can fix the pixelated look of the edges of the circles? I have set antialias: true in the renderer but it’s not doing anything.
Here’s my code:
const texture = new THREE.TextureLoader().load(PointPNG);
const material = new THREE.PointsMaterial({
color: 0x0000ff,
map: texture,
size: 50,
alphaTest: 0.1,
transparent: true,
});
The points need to be sorted before each render call in order to properly blend by alpha, except if you use additive blending then the order doesn’t matter.
I see, then you need sorting anyway. You can store each point in an array where you update a distance property (distance to camera), sort the array by it and write the positions by the sorted array to the points geometry position attribute, so you can use any kind of blending correctly and keep depth testing enabled.
It’s a specific usecase and there are couple ways to sort and deal with sorting or updating multiple attributes, for alphaTest only cases it wouldn’t be even necessary to sort.
Sorting is the only way, there are other options that you could explore, but not my knowledge all other ways such as order-independent transparency have too many other requirements to make them truly viable.
I use sorting in my particle engine too, for pretty much the same reasons.