PointsMaterial. How Do I Prevent Vanishing Points On Zoom Out?

I am using PointsMaterial to create an interactive “point cloud” from a dataset. Tens of thounds of points fill a large space. I have enabled size attenuation. As a result when dollying the camera out from the point clusters they progressively vanish as their screen space size falls below one pixel.

What strategy can I use to prevent disappearing points. One idea I have is to somehow clamp the minimum size of the points but I am not sure how to go about this.

1 Like

Are you sure that the vanishing points are not further than the far plane of the camera?

Yes. I have confirmed this by increasing the size of the points. The points remain visible for a longer time as I dolly out. I have also increased the far clip plane a significant amount.

You could clamp the gl_PointSize of your particles.
For this you would need to create custom shader as far as i know.
In the shader something like this worked for me:

    gl_PointSize = aSize;
    gl_PointSize *= ( scale / - mvPosition.z );
    gl_PointSize = clamp(gl_PointSize, minSize, maxSize);

scale = canvas.height * 0.5;
mvPosition = modelViewMatrix * vec4(position, 1.0);

I think the default implementation in PointsMaterial could be improved with above too…
for example the scale value depending on canvas height is a bit dodgy - shouldn’t it be min(canvas.height, canvas.width) ? For mobile it would make a difference i guess. slight off-topic though.