Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Exophysics – WebGL2 particle simulator (exophysics.net)
80 points by hut0 on Dec 7, 2020 | hide | past | favorite | 25 comments



Hey people, I built this particle simulator in ~500 lines of self-contained HTML/JS/WebGL2.

It's designed to encourage creativity and exploration. You can just download one of those universes and open up the HTML file in a text editor to tweak the physical laws and constants. Then open it up in your browser to see the result immediately.

I had a lot of fun exploring the beautiful emergent behaviors that arise from those simple rules, give it a try too! There's plenty of documentation and you don't need to be a programming wizard. :)

The most interesting universes I came up with are on display here: https://exophysics.net/exhibition.html


This is pretty fun, I like it, will take a look at the code later today.

> Finally, I am legally obliged to inform you of the one law of exophysics: > YOU ARE REQUIRED TO TERMINATE A SIMULATION IMMEDIATELY UPON FINDING > EVIDENCE OF THE EMERGENCE OF SENTIENT CREATURES CAPABLE OF SUFFERING.

LOL, I had to google "law of exophysics" to see if it is real.


I mean.. arguably... if the sentient creatures have emerged then is it ethical to kill them?


Well, factor in a slow extinction event and let it run for a few billion ticks. That way they have ample warning, and they might have even offed themselves within that timeframe.


True, but that law was established to discourage any research in that domain, reducing the overall occurences of sentience-incidents and the resulting messy philosophical questions.


I like this programming languages made for particle/fields [1,2,3]

Yoshiki Ohshima also made the particle/fields simulator in Squeak/Etoys that Alan Kay demos is his talks [5] and was a scientist at Alan Kay's VPRI [4].

[1] http://tinlizzie.org/~ohshima/shadama2/

[2] https://www.youtube.com/user/yoshikiohshima/search?query=sha...

[3] http://tinlizzie.org/~ohshima/shadama2/live2017/#kedama

[4] http://www.vpri.org/writings.php

[5] https://tinlizzie.org/IA/index.php/Talks_by_Alan_Kay


Wasn't aware of this project, thanks for the links!


Nice, this is really fun to play with!

I messed around with something similar a few years ago, based on (the code in) this video https://www.youtube.com/watch?v=Z_zmZ23grXE

Edit: Apparently there are a lot of these! This variant is also pretty cool (smaller particles, more like "fields"): https://www.youtube.com/watch?v=nu5aDIEoBk0


https://www.youtube.com/watch?v=makaJpLvbow <- this one is pretty awesome too. A very simple rule and quite the complex behavior. Though I'd recommend watching it at 175% speed, muted, and perhaps with the 1812 Overture as the background music.


Sweet, thank you for the links! I'll surely learn something from what they've been doing :)


I love the emphasis on user exploration. And your way of writing the documentation is very welcoming. Awesome tool.


Thank you :)!


If you don't mind me saying - poor naming and post title.

This is much more interesting than the keyword phrases "particle simulator" and "physics" would suggest!

Can you not cram something ALife related in there?


I don't know, I find the name pretty accurate – it is a particle simulator, after all.


It's a matter of specificity. Yes, it's a particle simulator, but given the Conway's Life feel to some of the examples, it at least seems like a high-speed, high-resolution cellular automata.


Thank you :) I can't edit it anymore, but will think of that next time.


None seem to work on Safari 14.0.01 :/ Not sure if I need to enable anything for WebGL.

On vanilla Chrome 87, I get "Unable to initialize the shader program: Vertex shader active uniforms exceed GL_MAX_VERTEX_UNIFORM_VECTORS(256)" for most of them.

But a few work (swyrlyx.html) and are super cool! Nicely done.


It's a pity that Safari is a little slow to implement WebGL2. Your message on chrome though sounds like a legit bug, since normally, Exophysics reduces the number of particles to match the hardware/browser capabilities, and here they're exceeded. Will investigate.


Safari 14 has WebGL 2, it just has to be turned on in the Develop menu first.


on Safari/macOS you can enable Develop | Experimental Features | WebGL 2.0


Safari does not support WebGL 2 by default. But Safari Technology Preview does.


Gelopia takes form of large microbes with tails made of hundreds of cells and they keep moving around.

Saldy, It doesn't work on chrome desktop though


I thought that WebGL2 didn't have compute shaders. How are you doing this without them?


I use transform feedback, which allows vertex shaders to send data back to the application. You could do this with textures as well, as described by pjmlp. I did this in an earlier version (https://github.com/hut/cellmade#) but it just felt SO WRONG. I was very happy that I found out about transform feedback to be able to do it more cleanly.

https://developer.mozilla.org/en-US/docs/Web/API/WebGLTransf...

> The WebGLTransformFeedback interface is part of the WebGL 2 API and enables transform feedback, which is the process of capturing primitives generated by vertex processing. It allows to preserve the post-transform rendering state of an object and resubmit this data multiple times.


You can fake it by misusing textures.

Actually there is a compute shaders extension, but it is only available in certain drivers configurations in Firefox.

Chrome only plans to support WebGPU.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: