r/generative • • Sep 27 '21

geometric avoidance

1.6k Upvotes

38 comments sorted by

77

u/j2rgb Sep 27 '21 edited Sep 27 '21

Running in real-time in WebGL with a handful of GLSL shaders.

- Generate random positions and directions for each particle.
- Particles travel in a direction until they hit the trail of any other particle, including their own, at which point generate a new direction.
- Edit: Some subset of the particles are influenced by an underlying noise field.

Also on twitter.com/j2rgb and instagram.com/j2rgb

12

u/NEED_A_JACKET Sep 27 '21

It seems to also sometimes change path without hitting anything too, is that intentional?

Some seem to try to stay on track (eg. bounce then return to their previous direction causing those little triangles etc).

Is there another part of the logic you've not mentioned above?

8

u/j2rgb Sep 27 '21

Yep, good eye. Some subset of the particles are influenced by an underlying noise field. I updated my comment to reflect this.

2

u/conventionistG Sep 28 '21

I spotted a couple hopping other lines. Just fyi. Looks cool.

33

u/rwp80 Sep 27 '21

this is possibly the clearest pseudo-code i've ever read!

2

u/quary1993 Sep 27 '21

this is awsome

1

u/Sumruv Sep 28 '21

Really really cool. It looks like when they bounce you choose a random direction from the allowed directions constrained to 45 degrees increments? Or maybe some constrained to 45 and others to 90? Do the noise particles have some minimum travel distance before updating their direction, or is it just very low res noise (or other)? I also noticed a few light blue particles passing through other trails

1

u/spaceguerilla Sep 28 '21

This is brilliant. I will now continue with my main hobby: hoping and praying that you and all the other talented people on r/generative will consider making AE plugins so that codeless non-programming plebs like myself can make things too!

1

u/[deleted] Sep 27 '21

Very cool, you are talented. How long did it take you?

8

u/arachnic Sep 27 '21

Hey, that's lovely ! Do you mind explaining the avoidance logic ? And is a flow-field involved at any point ? Thanks

11

u/j2rgb Sep 27 '21

> Do you mind explaining the avoidance logic ?
Particle trails are written to a color buffer which get sampled by another shader running the simulation in order to detect intersections.

> And is a flow-field involved at any point

Yes, some particles are influenced by a noise field.

1

u/arachnic Sep 28 '21

Yay ! Will try something on the Sunday.. Cheers !

1

u/jathar Sep 27 '21

Feel free to get more technical

3

u/Glitchhikers_Guide Sep 27 '21

What do you use to record/save these animations?

9

u/j2rgb Sep 27 '21

I run an express server that saves images to disk. The client code uses canvas.toDataURL to convert the webgl framebuffer to a png, which I then POST to the server running on localhost. I manually run ffmpeg on the resulting pngs to create gifs and mp4 at various resolutions.

7

u/Glitchhikers_Guide Sep 27 '21

Clever and over engineered. A programmer after my own heart lol. Thanks for the explanation.

12

u/iAccel Sep 27 '21

This is great. I really like the colors as well.

6

u/coffee869 Sep 27 '21

Reminds me of Hyper Light Drifter's palette

3

u/iAccel Sep 27 '21

Yeah even the isometric style is in there a bit.

9

u/DeepExhale Sep 27 '21

I don't know what the fuck this is but I could watch it like I watched the Windows XP pipe screensaver as a kid for hours.

12

u/DeepExhale Sep 27 '21

HOLY FUCK! The entire subreddit is like this! Ffs thank you so much OP.

2

u/rwp80 Sep 27 '21

I'm blown away by this, love it!

2

u/dontnormally Sep 27 '21

I love it.

2

u/_SmolBeannn_ Sep 27 '21

Pure eye candy, awesome

2

u/willymily Sep 27 '21

Everything about this is perfect.

2

u/the_Demongod Sep 27 '21

Reminds me of Armagetron Advanced

2

u/MrSplike Sep 27 '21

This is so cool! Have you tried it with the colors being associated with a specific movement logic? That could produce interesting results.

2

u/jolharg Sep 27 '21

If tron was allowed to go diagonally

2

u/[deleted] Sep 27 '21

Well THAT'S gorgeous.

2

u/RefrigeratorTheGreat Jan 23 '22

Powder game ants

1

u/daydus Sep 28 '21

Yo why this look like a map for a cyberpunk game

1

u/MildlySerious Sep 28 '21

If I wasn't already following you, I would now lol

Great job. Beautiful outcome and impressive work doing it all with shaders.

1

u/skarloni Sep 28 '21

Surprisingly satisfactory to watch! :)

1

u/[deleted] Apr 16 '22

Reminds me of an old TRON game