4 ms·
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 averag
by berniedurfee 3y ago
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. :)
- shnock 3y agoCould you share the repo?
- berniedurfee 3y agoI will, but I need to dig it out of my archives. It was from a time before repos. :)
- fjkdlsjflkds 3y ago> no calculus "set each pixel’s brightness to be the average brightness of the immediately adjacent pixels" sounds like a convolution ;)
- Cthulhu_ 3y agoIt's a trick! Calculus puts me right off, but explain it in code and visualizable ways and I'm on board.
- hyperthesis 3y agoThis 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 https://youtube.com/watch?v=ToIXSwZ1pJU
- berniedurfee 3y agoBah! I knew it! :)