TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: Metaballs

673 点作者 winkerVSbecks超过 7 年前

35 条评论

slavik81超过 7 年前
From the grandparent article:<p>&gt; Well, for 40 bouncing circles, on a 700x500 grid, that would be on the order of 14 million operations. If we want to have a nice smooth 60fps animation, that would be 840 million operations per second. JavaScript engines may be fast nowadays, but not that fast.<p>The math is super-cool, and efficiency is important for finding isosurfaces in higher dimensions, but those aren&#x27;t really scary numbers for normal programs. Just tinting the screen at 2880x1800 is ~2 million operations per frame. GPUs can handle it.<p>A simple way to render is to draw a quad for the metaball, using the metaball kernel function in the fragment shader. Use additive blending while rendering to a texture for the first pass, then render the texture to screen with thresholding for the second pass. The end result is per-pixel sampling of the isosurface.<p>Admittedly, it&#x27;s kind of a brute-force solution, but even the integrated GPU on my laptop can render thousands of metaballs like that at HiDPI resolutions.<p>(Specifically, I use a Gaussian kernel for my metaballs. It requires exp, which is more expensive computationally than a few multiplies. I render 1500 of them at 2880x1671 at 5ms per frame on an Intel Iris Pro [Haswell].)<p>Though, the work scales with fragment count, so a few large metaballs may be as costly many smaller ones. For large numbers of metaballs, you probably also want to use instancing so you&#x27;d need OpenGL ES 3.0 &#x2F; WebGL 2.0 which are fairly recent.<p>But 40 metaballs with a simple kernel at 700x500? That&#x27;s easy for a GPU.
评论 #15495258 未加载
评论 #15497637 未加载
femto113超过 7 年前
Feels more organic to me if the original metaball gets smaller as the other one moves out (like its stealing material). Haven&#x27;t worked out the correct math but a quick PoC is here:<p><a href="https:&#x2F;&#x2F;codepen.io&#x2F;femto113&#x2F;pen&#x2F;MEZava" rel="nofollow">https:&#x2F;&#x2F;codepen.io&#x2F;femto113&#x2F;pen&#x2F;MEZava</a>
评论 #15493509 未加载
评论 #15495269 未加载
评论 #15494207 未加载
评论 #15498322 未加载
mikewhy超过 7 年前
Reminds me of this demo from years ago: <a href="https:&#x2F;&#x2F;tympanus.net&#x2F;Development&#x2F;CreativeGooeyEffects&#x2F;menu.html" rel="nofollow">https:&#x2F;&#x2F;tympanus.net&#x2F;Development&#x2F;CreativeGooeyEffects&#x2F;menu.h...</a><p>Article for more detail: <a href="https:&#x2F;&#x2F;tympanus.net&#x2F;codrops&#x2F;2015&#x2F;03&#x2F;10&#x2F;creative-gooey-effects&#x2F;" rel="nofollow">https:&#x2F;&#x2F;tympanus.net&#x2F;codrops&#x2F;2015&#x2F;03&#x2F;10&#x2F;creative-gooey-effec...</a>
评论 #15496154 未加载
评论 #15497266 未加载
dmschaab超过 7 年前
Interesting approach! Coincidentally, I published an article [0] on this very topic last month. It uses sampling, so it&#x27;s close to the approach mentioned in the Jamie Wong article you (and I) linked to, but with a path-tracing step capable of producing an SVG path definition. I&#x27;d be interested to see how the performance of these two methods stack up to each other for a given quality level.<p>[0] <a href="https:&#x2F;&#x2F;eightsquaredsoftware.com&#x2F;articles&#x2F;metaball.html" rel="nofollow">https:&#x2F;&#x2F;eightsquaredsoftware.com&#x2F;articles&#x2F;metaball.html</a>
评论 #15494854 未加载
评论 #15494414 未加载
评论 #15499610 未加载
评论 #15495899 未加载
评论 #15495894 未加载
panic超过 7 年前
In <a href="https:&#x2F;&#x2F;codepen.io&#x2F;winkerVSbecks&#x2F;pen&#x2F;NazWxg" rel="nofollow">https:&#x2F;&#x2F;codepen.io&#x2F;winkerVSbecks&#x2F;pen&#x2F;NazWxg</a>, there&#x27;s a &quot;hitch&quot; as the discs touch due to a first-derivative discontinuity. Here&#x27;s a version which extrapolates the u1 and u2 variables, making the transition much smoother: <a href="https:&#x2F;&#x2F;codepen.io&#x2F;panic_&#x2F;pen&#x2F;BwvjmK" rel="nofollow">https:&#x2F;&#x2F;codepen.io&#x2F;panic_&#x2F;pen&#x2F;BwvjmK</a>.
评论 #15494019 未加载
评论 #15494011 未加载
bpicolo超过 7 年前
That bubble slider is super cute. <a href="https:&#x2F;&#x2F;codepen.io&#x2F;chrisgannon&#x2F;pen&#x2F;GZNgLw" rel="nofollow">https:&#x2F;&#x2F;codepen.io&#x2F;chrisgannon&#x2F;pen&#x2F;GZNgLw</a>
评论 #15493530 未加载
microcolonel超过 7 年前
Good to see you on the front page, Varun. :- )<p>It&#x27;s possible to do this <i>somewhat</i> efficiently beyond two balls with GLSL and lots of uniforms (or a UBO), since metaballs from the graphics perspective are really just distance fields.<p>If you want more than a few balls, you can do it in two passes: one to produce the distance field, and one to threshold it.<p>As an added benefit, it&#x27;s straightforward to generalize these approaches to any two-dimensional continuous function.
评论 #15493702 未加载
评论 #15492734 未加载
评论 #15494006 未加载
评论 #15492837 未加载
winkerVSbecks超过 7 年前
For everyone complaining about the lack of meatballs… here are some: <a href="https:&#x2F;&#x2F;codepen.io&#x2F;winkerVSbecks&#x2F;full&#x2F;oGJLwo&#x2F;" rel="nofollow">https:&#x2F;&#x2F;codepen.io&#x2F;winkerVSbecks&#x2F;full&#x2F;oGJLwo&#x2F;</a>
Const-me超过 7 年前
The math can be optimized by at least an order of magnitude.<p>Trigonometry functions are expensive, especially the reverse ones.<p>If v=0.5, see [1] for how to find out sine&#x2F;cosine of a maxSpread * v. For angleBetweenCenters + maxSpread * v, see [2] for how to find sine + cosine of a sum of angles.<p>If you’ll do all that math in the symbolic form (you can use Maple or Mathematica or something similar), you’ll get the equivalent formulae for p1-p4 that won’t use any trigonometry, only simple math and probably a square root.<p>[1] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;List_of_trigonometric_identities#Half-angle_formulae" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;List_of_trigonometric_identiti...</a> [2] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;List_of_trigonometric_identities#Angle_sum_and_difference_identities" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;List_of_trigonometric_identiti...</a>
评论 #15497708 未加载
santaclaus超过 7 年前
&gt; Metaballs, not to be confused with meatballs<p>I once reviewed an academic paper at a major CS conference that misspelled metaballs as meatballs throughout.
评论 #15493339 未加载
评论 #15493616 未加载
评论 #15492791 未加载
mileycyrusXOXO超过 7 年前
I just started learning GLSL shaders. As practice, I wrote a psuedo-metaball joystick. I didn&#x27;t know about metaballs, but now that I do I can do some more research and improve my next iteration.<p>Touch blob joystick shader: <a href="https:&#x2F;&#x2F;www.shadertoy.com&#x2F;view&#x2F;4lfcRf" rel="nofollow">https:&#x2F;&#x2F;www.shadertoy.com&#x2F;view&#x2F;4lfcRf</a>
spitfire超过 7 年前
<a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=L_lD7iqG8nA" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=L_lD7iqG8nA</a><p>About 2 minutes in there&#x27;s an excellent realtime metaballs implementation that ran smoothly on a 486-66mhz. Metaballs were an extremely popular effect in the early 90&#x27;s.
评论 #15494605 未加载
shove超过 7 年前
Paper.js is truly a great source of vector drawing tricks. Curious how difficult it would be to extend this technique beyond two circles. Might have to dust off some old experiments ... :)
philipov超过 7 年前
Oh no... I shook it a bunch and it broke apart ;_;
zokier超过 7 年前
Metaballs are always nice, but I think this page (that was linked in the article) that shows compass&amp;straight-edge constructions to be especially nifty:<p><a href="http:&#x2F;&#x2F;www.mathopenref.com&#x2F;consttangentsext.html" rel="nofollow">http:&#x2F;&#x2F;www.mathopenref.com&#x2F;consttangentsext.html</a>
评论 #15495794 未加载
theoh超过 7 年前
During or just before WW2, Roy Liming developed analytic techniques for calculating a similar class of blend or fillet. They were taken up in aircraft design, a field that I can&#x27;t imagine ever using implicit surfaces! I think it was Edgar Schmued&#x27;s design for the P-51 Mustang that famously used Liming&#x27;s work.<p>Liming wrote a book, but it&#x27;s rare. Some technical discussion towards the end of this page: <a href="http:&#x2F;&#x2F;homepages.inf.ed.ac.uk&#x2F;rbf&#x2F;CVonline&#x2F;LOCAL_COPIES&#x2F;BOWYER1&#x2F;c6.htm" rel="nofollow">http:&#x2F;&#x2F;homepages.inf.ed.ac.uk&#x2F;rbf&#x2F;CVonline&#x2F;LOCAL_COPIES&#x2F;BOWY...</a>
ladon86超过 7 年前
Was this the technique used in World of Goo?
评论 #15492740 未加载
asadlionpk超过 7 年前
This actually refreshes my memory. I had to implement some metaballs myself some years back for a fluid simulation.<p>I had to struggle with metaball rendering on canvas back then. It was so slow. Now I guess a pixel shader in webGL can do a better job.<p>Check this out too: <a href="https:&#x2F;&#x2F;asadmemon.com&#x2F;SPHjs&#x2F;" rel="nofollow">https:&#x2F;&#x2F;asadmemon.com&#x2F;SPHjs&#x2F;</a> source: <a href="https:&#x2F;&#x2F;github.com&#x2F;asadm&#x2F;SPHjs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;asadm&#x2F;SPHjs</a>
christotty超过 7 年前
An alternative method (with potentially different applications) that I found interesting. The visual aids in both articles are very good.<p><a href="http:&#x2F;&#x2F;jamie-wong.com&#x2F;2014&#x2F;08&#x2F;19&#x2F;metaballs-and-marching-squares&#x2F;" rel="nofollow">http:&#x2F;&#x2F;jamie-wong.com&#x2F;2014&#x2F;08&#x2F;19&#x2F;metaballs-and-marching-squa...</a>
fzaninotto超过 7 年前
We&#x27;ve use the blur+contrast approach successfully in EventDrops [1], a time series visualisation based on d3.js. It all happens client-side, with OK performance. Not sure the SVG approach brings more in this case.<p>[1] <a href="https:&#x2F;&#x2F;marmelab.com&#x2F;EventDrops&#x2F;" rel="nofollow">https:&#x2F;&#x2F;marmelab.com&#x2F;EventDrops&#x2F;</a>
a_e_k超过 7 年前
Andrew Glassner published a paper on something extremely similar back in 2015:<p>&quot;Globs: A Primitive Shape for Graceful Blends Between Circles&quot;<p><a href="http:&#x2F;&#x2F;jcgt.org&#x2F;published&#x2F;0004&#x2F;03&#x2F;01&#x2F;" rel="nofollow">http:&#x2F;&#x2F;jcgt.org&#x2F;published&#x2F;0004&#x2F;03&#x2F;01&#x2F;</a>
davidkuhta超过 7 年前
This is pretty awesome.<p>I wonder how much would need to be adjusted to provide a scaling factor to the first metaball such that the area was constant (Thus ending up with two equally sized metaballs) or even utilizing the speed of the pull in determining the second balls size.
memco超过 7 年前
This is cool. Just watched a related talk from Casey Muratori about this yesterday: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=SDS5gLSiLg0" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=SDS5gLSiLg0</a>
macca321超过 7 年前
What&#x27;s the practical, commercial use for something like this? It looks like it must take a lot of time and effort to get this right.<p>Or is this university stuff? Or even spare time stuff?
corprew超过 7 年前
I clicked through this hoping that someone had done a &#x27;Show HN&#x27; for a literal plate of meatballs.
robodale超过 7 年前
I keep seeing Metaballs as Meatballs.
评论 #15496169 未加载
staticelf超过 7 年前
I am from Sweden and read &quot;meatballs&quot; when I clicked. Just imagine my disappointment.<p>Cool stuff though.
fibo超过 7 年前
there is a popular vvvv shader that implements metballs, see <a href="https:&#x2F;&#x2F;vvvv.org&#x2F;blog&#x2F;debug2-2" rel="nofollow">https:&#x2F;&#x2F;vvvv.org&#x2F;blog&#x2F;debug2-2</a>
Osmium超过 7 年前
Could this extend to 3D?
评论 #15492982 未加载
评论 #15492580 未加载
评论 #15493376 未加载
评论 #15493068 未加载
评论 #15492816 未加载
评论 #15492649 未加载
评论 #15493579 未加载
评论 #15492986 未加载
评论 #15492570 未加载
mgalka超过 7 年前
Surprised I&#x27;ve never seen metaballs before. Very cool.
mar77i超过 7 年前
I prefer Regular Ordinary Swedish Metaballs™
retor超过 7 年前
That&#x27;s one spacey metaball! (sorry...)
fenollp超过 7 年前
&gt;CodePen requires a referrer to render this. Your browser isn&#x27;t sending one.<p>Interesting.
评论 #15492783 未加载
fairpx超过 7 年前
I would love to incorporate this in some of the UI design work we do for startups. Are there more similar libraries available? We could reference it to our network of clients (mostly developer driven startups) to help translate some of the design ideas we propose. If you know of other similar projects like Metaballs, please do share below or ping me (details in my bio)
alex_suzuki超过 7 年前
I was disappointed that this was not about meatballs, for I am hungry.