How to improve metaballs render time with larger point clouds?

edited April 2018 in How To...

My understanding of 2d metaballs is you loop through every pixel in an array and measure the distance of each pixel to every particle and depending on the distance you give that pixel a value. However, this means you are running dist() function for every particle, for every pixel. Meaning a 600x600 square with 1000 particles is 360 million dist() checks plus the other formulas you need to get the value, which could easily be a billion lines of code to render 1 frame. Is there some method to do those checks in clusters and maybe there is a totally different way to do metaballs which can use the graphics card or concurrent processing? What is the most efficient way to render a point cloud?

Answers

  • It sounds possible to do in shader.
    Have you written an un-optimized version?

  • 1000 particles in a 600x600 square? even if each one was tiny, like 10 pixels radius, they'd fill the canvas. 100 is probably too many.

    if you use the inverse-squared law to determine the influence of each particle on each pixel then you can get rid of the sqrt in the distance calculations because they cancel out. much less work.

  • edited April 2018

    @prince_polka - I actually came up with a method which I used in my smoke simulation. However the performance optimizations that I came up with all have to do with limiting the number of checks by changing what is essentially the resolution.

    @koogs, in this case the particles are simply points or PVectors. Essentially a point cloud to model things like fluids or generate dynamic textures.

Sign In or Register to comment.