5 ms·
Improving the foundation of our falling sand simulator
- dang 4y agoRecent and related: Making a falling sand simulator - https://news.ycombinator.com/item?id=31309616 https://news.ycombinator.com/item?id=31309616 - May 2022 (65 comments)
- d4a 4y agoThe acceleration was my main gripe with the previous iteration. Thanks for adding it! I want to stay up to date on this blog. Is there an RSS feed anywhere?
- jasonjmcghee 4y agoI'm glad you are enjoying the posts! I'm hosting on Github Pages, which seems to have a feed plugin for RSS, so I'll investigate that! Right now I've just been posting to Twitter (so far it's the only thing I've used it for) and HN.
- jakear 4y agoLove the gravity addition, that's a clever trick for dealing with fractional velocity. Pausing rendering when there are no changes is also a nice touch. I notice on my machine the background is initially white and only acquires the grey background color after a sand has fallen past a given pixel. I encountered the same bug when building my own version off of this from your last post, my fix was to initialize the dirty set to be the full set of indexes for the first frame. Also, some of the buttons are pure white, the text is invisible. (I suspect both of these are light mode only bugs)
- jasonjmcghee 4y agoOh no! I clearly have a bug. I develop in dark mode and apparently broke something during this post and didn't verify light mode. I will look into it now!
- jasonjmcghee 4y agoThe light mode bugs should now be fixed. Apologies for that.
- jakear 4y agoWorks great!
- jasonjmcghee 4y agoI thought treating fractional velocity as the probability to move was a fun hack. Unlike rounding, it makes it feel a bit more fluid as the batch of particles placed at a time step move two different distances.
- Bellend 4y agoThis is really awesome! Anyone remember Sony-J5 Mobile? I first seen falling sand there. Jason's version is a ultra fast version (and cool!). https://www.sony.ee/electronics/support/res/manuals/3227/32275282M.pdf https://www.sony.ee/electronics/support/res/manuals/3227/322...
- ajmurmann 4y agoOn Safari and Chrome I get `TypeError: p.before is not a function. (In 'p.before()', 'p.before' is undefined)` from falling-improved:171 Nothing gets rendered.
- jasonjmcghee 4y agoThis is what happens when you try to fix a bug while your post is on the front page. Yikes. Should be fixed. You might need to force refresh.
- deleted 4y ago[deleted]
- sokoloff 4y agoFun! Small bug: if you two finger touch on iOS (or hit clear all), the screen clears to a different color background, lighter than the new sand dispenser, so now the sky becomes darker as you drag around.
- jasonjmcghee 4y agoShould be fixed now! Apologies for that! Clearly needed to test light mode more thoroughly.
- guerrilla 4y agoWow why is this so fun and joyful :) So satisfying...
- Jarmsy 4y agoNice! How about a 3d version? :)
- jasonjmcghee 4y agoIf there's interest, I can definitely take a crack at it! My current plan was to introduce some new particle types as there is some pretty stimulating emergent behavior that comes out particles with different rules interacting with one another. I'm also really interested in exploring 2D velocity and acceleration- how we could go about enabling particles to be thrown and bounce off of walls- or each other.
- DylanSp 4y agoIf you don't mind spoiling your plans, are you thinking of continuing with the subclass-per-particle type approach, or eventually moving to something like a simple ECS architecture?
- jasonjmcghee 4y agoA full ECS architecture? I don't plan on it. But using some sort of trait / component structure could be worth if enough particles with a mixture of different and overlapping behaviors were introduced.
- c0nsumer 4y agoThere's something about the feeling of this that reminds me of being much younger, running demos in DOS, and how insanely performant they'd be at running the same sort of thing. It was like magic at those times. This is so far abstracted from the magic hyperoptimizations that were used for those demos it's mindblowing, but it's still fun to see and neat to play with.
- makeworld 4y agoThese days when I want a falling sand game, I go to https://sandspiel.club/ https://sandspiel.club/
- jasonjmcghee 4y agoAbsolutely! I mentioned it in my first post. Great implementation and a good blog post about how it's made.
- Doxin 4y agoAllow me to recommend The Powder Toy[0]. It is to date, as far as I can tell, The most advanced falling sand game available, aside from maybe Noita, though the focus there is quite different from most falling sand games. It has hundreds of different elements to play with. It simulates air pressure and can with the toggle of a button simulate ambient heat, water pressure, and newtonian gravity. People have built everything from bombs to CPUs in it. Disclaimer: I did some minor development work on TPT and am involved in the community. Still though, great game. [0] https://powdertoy.co.uk/ https://powdertoy.co.uk/
- steve_adams_86 4y agoNice, I’m glad to see another post from you! As someone else mentioned, this has intense nostalgic vibes. Something about the acceleration of the sand maybe? You really knocked it out of the park in any case, the end result is fantastic. I’m looking forward to digging in deeper.
- serenitylater 4y agoHave you thought about modeling aeolian transport (wind-blown sand?) the mechanics of it are poorly understood and this could be a decent starting point. I know the other models attempting to capture aeolian transport are extremely lacking.
- panzerboiler 4y agoVery nice job. You did some massive improvements since the previous article. I will try to follow along with a GPGPU implementation. Thank you!
- jasonjmcghee 4y agoThank you! I'd be very interested to see that. I've had a couple of fun Sundays now. I'm looking forward to the next pieces- but moving the logic to the gpu (either by shaders or GPGPU) has not been something I've been planning to do.
- panzerboiler 4y agoThe simulation being massively parallel, it is a perfect fit for a fragment shader. Since the interactions between the particles are mostly local, taking advantage of the fact that the GPU loads a block of neighbouring fragments in the cache to be able to compute the standard derivatives, it should run very well. I will notify you when I find some time to play with it.
- bowsamic 4y agoNothing like some good old elegant untyped JS
- cjg 4y agoReminds me of the 1991 Archimedes game Cataclysm.
- deleted 4y ago[deleted]
- deleted 4y ago[deleted]
- ge96 4y agoCan't restart it after it falls?
- jasonjmcghee 4y agoYou can just click "Clear All". Or right click on Web / tap with two fingers on mobile.