Live data from Hacker News

Simulating fluids, fire, and smoke in real-time

andrewkchan.dev

101–110 of 174 posts

Re: Simulating fluids, fire, and smoke in real-time

#102

As a person who did a PhD in CFD, I must admit I never encountered the vorticity confinement method and curl-noise turbulence. I guess you learn something new every day! Also, in industrial CFD, where the Reynolds numbers are higher you'd never want something like counteracting artificial dissipation of the numerical method by trying to applying noise. In fact, quite often people want artificial dissipation to stabil…

I think the curl noise paper is from 2007: https://www.cs.ubc.ca/~rbridson/docs/bridson-siggraph2007-cu... I've used the basic idea from that paper to make a surprisingly decent program to create gas-giant planet textures: https://github.com/smcameron/gaseous-giganticus

Hey that paper references me. ;) I published basic curl noise a few years before that in a Siggraph course with Joe Kniss. Bridson’s very cool paper makes curl noise much more controllable by adding the ability to insert and design boundary conditions, in order words, you can “paint” the noise field and put objects into the noise field and have particles advect around them. Mine and Joe’s version was a turbulence field based on simply taking the curl of a noise field because curl has the property of being incompressible. Thought about it after watching some effects breakdown on X-men’s Nightcrawler teleport effect and they talked about using a fluid simulation IIRC to get the nice subtleties that incompressible “divergence-free” flows give you. BTW I don’t remember exactly how they calculated their turbulence, I have a memory of it being more complicated than curl noise, but maybe they came up with the idea, or maybe it predates X-men too; it’s a very simple idea based on known math, fun and effective for fake fluid simulation.

We liked to call it “curly noise” when we first did it, and I used it on some shots and shared it with other effects animators at DreamWorks at the time. Actually the very first name we used was “curl of noise” because the implementation was literally curl(noise(x)), but curly noise sounded better/cuter. Curly noise is neat because it’s static and analytic, so you can do a fluid-like looking animation sequence with every frame independently. You don’t need to simulate frame 99 in order to render frame 100, you can send all your frames to the farm to render independently. On the other hand, one thing that’s funny about curly noise is that it’s way more expensive to evaluate at a point in space than a voxel grid fluid update step, at least when using Perlin noise which is what I started with. (Curly noise was cheaper than using PDI’s (Nick Foster’s) production fluid solver at the time, but I think the Stam semi-Lagrangian advection thing started making it’s way around and generally changed things soon after that.)

BTW gaseous giganticus looks really neat! I browsed the simplex noise code for a minute and it looks gnarly, maybe more expensive than Perlin even?

Re: Simulating fluids, fire, and smoke in real-time

#103
post #50
post #4

Earlier quoted context omitted.

Yes, we can since a long time. They were already a thing 14 years ago on the PS3 in the game "Pixeljunk shooter" [0]. But real time simulations often use massive simplifications. They aim to look real, not to match exact solutions of the Navier-Stokes equations. [0] https://www.youtube.com/watch?v=qQkvlxLV6sI

Heck, the Wii had Fluidity around the same time period (2010), and that's a lot weaker than the PS3. Fluidity was pretty neat—you played as a volume of water, changing states as you moved through a level that looked like a classic science textbook: https://youtu.be/j7IooyXp3Pc?si=E79rCrq2mdyZSKoF&t=120

Well, technically yes.

Both use the same technique: Smoothed Particle Hydrodynamics.

But the PS3 was able to fill the whole screen with these particles. Hundreds of them. The game Fluidity seems to have approx. 20.

Re: Simulating fluids, fire, and smoke in real-time

#104
post #85

Earlier quoted context omitted.

At some point every render-engine builder goes through the exercise of imagining purely physically-modeled photonic simulation. How soon one gives up on this computationally intractable task with limited marginal return on investment is a signifier of wisdom/exhaustion. And, yes, I've gone way too far down this road in the past.

Not being a graphics person, is this what hardware ray tracing is, or is that something different?

Rayteacing doesn't simulate light, it simulates a very primitive idea of light. There's no diffraction, no interference patterns. You can't simulate the double-slit experiment in a game engine, unless you explicitly program it.

Our universe has a surprising amount of detail. We can't even simulate the simplest molecular interactions fully. Even a collision of two hydrogen atoms is too hard - time resolution and space resolution is insanely high, if not infinite.

Re: Simulating fluids, fire, and smoke in real-time

#105
post #76

Earlier quoted context omitted.

“Everything is smoke and mirrors in computer graphics - especially the smoke and mirrors!”

This was the big realization for me when I got into graphics - everything on the screen is a lie, and the gestalt is an even bigger lie. It feels similar to how I would imagine it feels to be a well-informed illusionist - the fun isn’t spoiled for me when seeing how the sausage is made - I just appreciate it on more levels.

A VP at Nvidia has a cool (marketing) line about this, regarding frame generation of "fake" frames. Because DLSS is trained on "real" raytraces images, they are more real than conventional game graphics.

So the non-generated frames are the "fake frames".

Re: Simulating fluids, fire, and smoke in real-time

#106

I wrote a super simple flame simulation a long time ago as a toy in C after reading an article somewhere. You just set each pixel’s brightness to be the average brightness of the immediately adjacent pixels. Calculate from bottom to top. Add a few “hot” pixels moving back and forth along the bottom and boom, instant fire. Looks very cool for a tiny amount of code and no calculus. :)

This is the laplacian operator (in 1D, just the second derivative, or curvature). The sharper the crest, the more negative; the sharper the trough, the more positive. If you change the value there, by that much, the effect is averaging (and the discretized form is literally averaging).

You've been doing calculus the whole time. There's a difference between knowing the path, and walking the path.

Here's a 3Blue1Brown video with intuitive graphics on it https://youtube.com/watch?v=ToIXSwZ1pJU

Re: Simulating fluids, fire, and smoke in real-time

#107
post #95

Earlier quoted context omitted.

Even the ray tracing / path tracing is half-fake these days cause it's faster to upscale and interpolate frames with neural nets. But yeah in theory you can simulate light realistically

It’s still a model at the end of the day. Material properties like roughness are approximated with numerical values instead of being physical features. Also light is REALLY complicated when you get close to a surface. A light simulation that properly handles refraction, diffraction, elastic and inelastic scattering, and anisotropic material properties would be very difficult to build and run. It’s much easier to use…

If I understood Feynman’s QED at all, light gets quite simple once you get close enough to the surface. ;) Isn’t the idea was that everything’s a mirror? It sounds like all the complexity comes entirely from all the surface variation - a cracked or ground up mirror is still a mirror at a smaller scale but has a complex aggregate behavior at a larger scale. Brian Green’s string theory talks also send the same message, more or less.

Re: Simulating fluids, fire, and smoke in real-time

#108
post #70

Earlier quoted context omitted.

Was the PhD worth it in your opinion?

Hard to say whether economically a PhD always makes sense, but it certainly can open doors that are otherwise firmly closed.

Well, sure. Everything you end up doing in life will open doors that would have otherwise remained firmly closed if you did something else instead.

Re: Simulating fluids, fire, and smoke in real-time

#109
post #107
post #95

Earlier quoted context omitted.

It’s still a model at the end of the day. Material properties like roughness are approximated with numerical values instead of being physical features. Also light is REALLY complicated when you get close to a surface. A light simulation that properly handles refraction, diffraction, elastic and inelastic scattering, and anisotropic material properties would be very difficult to build and run. It’s much easier to use…

If I understood Feynman’s QED at all, light gets quite simple once you get close enough to the surface. ;) Isn’t the idea was that everything’s a mirror? It sounds like all the complexity comes entirely from all the surface variation - a cracked or ground up mirror is still a mirror at a smaller scale but has a complex aggregate behavior at a larger scale. Brian Green’s string theory talks also send the same message,…

Sure, light gets quite simple as long as you can evaluate path integrals that integrate over the literally infinite possible paths that each contributing photon could possibly take!

Also, light may be simple but light interaction with electrons (ie. matter) is a very different story!

Re: Simulating fluids, fire, and smoke in real-time

#110

EmberGen is absolutely crazy software that does simulation of fire and smoke in real-time on consumer GPUs, and supports a node-based workflow which makes it so easy to create new effects. Seriously, my workflow probably went from spending hours on making something that now takes minutes to get right. https://jangafx.com/software/embergen/ I was sure that this submission would be about EmberGen and I'm gonna be hones…

Yes this is fantastic. One of the best software currently available in the market.
Post reply on HN