Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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


Bah! I knew it! :)


> no calculus

"set each pixel’s brightness to be the average brightness of the immediately adjacent pixels" sounds like a convolution ;)


It's a trick! Calculus puts me right off, but explain it in code and visualizable ways and I'm on board.


Could you share the repo?


I will, but I need to dig it out of my archives. It was from a time before repos. :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: