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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Show HN: WASM and WebGL Fluid Simulation

86 点作者 Birch-san将近 4 年前

17 条评论

Birch-san将近 4 年前
Author here. This demo showcases liquidfun-wasm[0], my effort to revive liquidfun[1] (a fork which adds fluid simulation and soft-body physics to Box2D[2]).<p>to make liquidfun-wasm, I repurposed my existing box2d-wasm[3] and pointed it at a different release of Box2D — a commit obtained by rebasing liquidfun over 7 years of upstream Box2D changes[4]. the end result is that liquidfun is now distributed in WebAssembly and with TypeScript typings for the first time. The TypeScript typings are generated from WebIDL bindings via my webidl-to-ts[5] compiler.<p>this demo in particular aims to bring to the Web the shaders from the liquidfun EyeCandy demo[6], and show how fast JS can run if you avoid incurring the garbage collector (the main loop tries not to allocate objects). the demo repurposes gravity and drag calculations that I&#x27;d used previously in my Lunar Survey experiment[7] (a Mario Galaxy homage).<p>[0] <a href="https:&#x2F;&#x2F;github.com&#x2F;Birch-san&#x2F;box2d-wasm&#x2F;releases&#x2F;tag&#x2F;liquidfun-v6.0.4-lf.1" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Birch-san&#x2F;box2d-wasm&#x2F;releases&#x2F;tag&#x2F;liquidf...</a><p>[1] <a href="http:&#x2F;&#x2F;google.github.io&#x2F;liquidfun&#x2F;" rel="nofollow">http:&#x2F;&#x2F;google.github.io&#x2F;liquidfun&#x2F;</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;erincatto&#x2F;box2d" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;erincatto&#x2F;box2d</a><p>[3] <a href="https:&#x2F;&#x2F;github.com&#x2F;Birch-san&#x2F;box2d-wasm" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Birch-san&#x2F;box2d-wasm</a><p>[4] <a href="https:&#x2F;&#x2F;github.com&#x2F;Birch-san&#x2F;box2d-wasm&#x2F;releases&#x2F;tag&#x2F;v4.0.0-liquidfun.0" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Birch-san&#x2F;box2d-wasm&#x2F;releases&#x2F;tag&#x2F;v4.0.0-...</a><p>[5] <a href="https:&#x2F;&#x2F;github.com&#x2F;Birch-san&#x2F;box2d-wasm&#x2F;tree&#x2F;master&#x2F;webidl-to-ts" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Birch-san&#x2F;box2d-wasm&#x2F;tree&#x2F;master&#x2F;webidl-t...</a><p>[6] <a href="https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;liquidfun&#x2F;blob&#x2F;master&#x2F;liquidfun&#x2F;Box2D&#x2F;EyeCandy&#x2F;engine.cpp" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;liquidfun&#x2F;blob&#x2F;master&#x2F;liquidfun&#x2F;Bo...</a><p>[7] <a href="https:&#x2F;&#x2F;birchlabs.co.uk&#x2F;lunar-survey&#x2F;" rel="nofollow">https:&#x2F;&#x2F;birchlabs.co.uk&#x2F;lunar-survey&#x2F;</a>
semi-extrinsic将近 4 年前
Compared to the original liquidfun tests, e.g. the wave tank, this looks a lot more unstable and has more of a tendency to form solid-like crystal structures inside the liquid, which damp out total momentum faster than you want. I suspect you could improve the realism quite a bit by tuning either time step size (downwards) or the particle interaction strength. Or there is a bug introduced somewhere in the rebasing process.
评论 #28077377 未加载
评论 #28035315 未加载
TazeTSchnitzel将近 4 年前
<a href="http:&#x2F;&#x2F;madebyevan.com&#x2F;webgl-water&#x2F;" rel="nofollow">http:&#x2F;&#x2F;madebyevan.com&#x2F;webgl-water&#x2F;</a> is a decade old but still impresses me. The water caustics are particularly neat.
评论 #28077517 未加载
zbendefy将近 4 年前
Awesome! Does it use wasm-simd? If it does do you know how much impact it has on the performance?
评论 #27999068 未加载
VinLucero将近 4 年前
I worked on this at Google!<p>We built another open source example app called Voltair based on LiquidFun:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;VoltAir" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;VoltAir</a>
评论 #28034185 未加载
评论 #28033575 未加载
inDigiNeous将近 4 年前
Nice to see such a high performance demo running on web technologies, gives me trust that we can finally do more complex and jitter-free graphics on web-applications.<p>Thanks for sharing and creating this.
Loeffelmann将近 4 年前
Could you train a ML model that fills in the gaps in the fluid simulation like they do in ray tracing?
mrspeaker将近 4 年前
This looks great - I like how the &quot;simple shader&quot; version gives a sense for how it works under the hood.<p>Is the implementation of it related to real-world mechanisms, or is it all smoke-and-mirrors that happens to look like real-world liquids? (Or, is the distinction non-important?!)
评论 #28077403 未加载
评论 #28033629 未加载
LinguaBrowse将近 4 年前
&gt; Built with box2d-wasm&#x27;s liquidfun release.<p>Very nice! How does this relate to the Google official release of Liquidfun, and the mainline release of Box2D?
评论 #27996960 未加载
kitd将近 4 年前
Very impressed by how well this works on mobile.
faeyanpiraat将近 4 年前
It works on iphone 7 but the page does a refresh 2 seconds in to a fallback page then again to s “problem occured” page
Loeffelmann将近 4 年前
Could you train a ML model that smoothes out the fluid simulation like they do with ray tracing?
评论 #28035325 未加载
_448将近 4 年前
What is the total size of the webpage that is downloaded to the user system?
评论 #28077467 未加载
Zababa将近 4 年前
It looks really good! Gravity, drag and temporal blend make nice visual effects.
Kiro将近 4 年前
Is this faster than a regular JS+WebGL version?
评论 #28034176 未加载
smerik将近 4 年前
Looks amazing!
dumindaxsb将近 4 年前
This is cool!