r/generative • • Feb 08 '22

Perspective Packing

https://gfycat.com/sardonicdirtyemu
1.1k Upvotes

44 comments sorted by

17

u/gliese946 Feb 08 '22

It looks amazing. Would it be possible to pack them in the XZ plane too, so you could rotate the whole thing around a horizontal axis as well? I can't figure out how you would generate a set of coordinates that worked but it feels like it should be possible.

3

u/tasty_plots Feb 08 '22

Yes, i'm rendering one like that tonight. Didn't do it in an efficient way, but i'm sure there must be one

2

u/gliese946 Feb 09 '22

I'd like to see it! Will you please post a link in a reply to this comment, if you make a new post?

1

u/tasty_plots Feb 09 '22

Something went wrong so i'm going to have to render again. But when I post it I'll put a comment

21

u/Derpasauruss Feb 08 '22

2D packing of 10000 spheres along 3 axis https://imgur.com/a/hBnpoQx

7

u/gliese946 Feb 09 '22

Cool! From the second gif it looks like the algorithm is: start with spheres no bigger than a certain radius. Choose a random point as center, and if it is unobscured in all 3 elevations, make a new sphere centered there, as big as possible up to the limit radius. Repeat. As you go, the shrinking space available will mean that the spheres you can plot, when you find an unobscured center, get smaller and smaller.

9

u/Derpasauruss Feb 09 '22 edited Feb 09 '22

You're pretty close! It is set up so spheres spawn at a very small radius and grow by 0.001 every frame. Of course, each spawn and growth event is checked against all 3 projections.

The only difference between the two scenes is that the first one (other than being fully grown at the start) spawns new spheres at a much slower rate - that allows the initial few spawns to grow much bigger.

I am happy to share the .tox if you would like to check it out! It's based on this tutorial:

https://youtu.be/r3aOQMB7qiI

I only had to do a few modifications to get it working along 3 axis. Honestly it only took an hour or two after starting that video to set up the final 3 axis algorithm, I spent twice as many hours getting the camera path/rotations to look decent lol 😂

Edit: here is the project file if anyone wants to check it out: https://github.com/dhef2543/Touchdesigner-ProjectFiles/blob/main/Circle%20Packing%203%20Axis.9.toe

2

u/gliese946 Feb 09 '22

Thanks for the explanation! What exactly happens to the rotation in the last part of the animation when the cube, and its contents, seems like it's been turned inside-out? Or are the cube edges just misdrawn so the front edges no longer cross in front of the spheres like they should?

3

u/Derpasauruss Feb 09 '22

Heh, I added the white cube edges to try to make it more clear which face of the cube is closer to the camera during the rotations, however if you expect an edge to come out in front of all of the spheres and it is actually behind it creates that weird miss-drawn / inside-out illusion. I've watched those videos probably 30 times and it still happens to me even though I know which face is actually in front.

I promise the box is drawn around the spheres correctly through the whole clip, it's just that the orthographic projection is messing with your brain because you expect the rear face to appear smaller / further away than the closer face (natural perspective).

2

u/gliese946 Feb 09 '22

That's funny! I wondered if it was a Necker-cube thing playing tricks on me, and I watched several times, and each time it happened at the same time (when the rotations become continuous), and I couldn't make my brain see it in a normal way. I wonder why my brain insists on seeing the wrong edge as "forward" at that point in the animation--it must be something about the sequence of rotations that gives rise to the expectation of a particular continuation. I just tried a few more times, and once I was able to watch the whole thing without it turning inside-out.

1

u/Derpasauruss Feb 09 '22

Yeah, it's tough to keep it straight all the way through. Especially during that last continuous rotation - once you see it backwards it's very hard to flip your brain's perspective back to the correct front corner.

I considered slowing the animation down to make it easier to perceive front/back correctly during that final rotation, but it's already a 40 second loop and the confusion adds another fun layer to the scene so I kept it as is.

I've never heard of the Necker cube before so thanks for sharing, that describes this illusion perfectly. It would be a real mind-fuck to render this scene with the bounding box as an impossible cube, if I can think of a way to do it that isn't overly complicated I'll give it a shot!

7

u/Jillesoom Feb 08 '22

Are there spheres hiding behind others on some Rotation, or can you see all of them at every Plane?

8

u/tasty_plots Feb 09 '22

There will be some behind as it rotates but when its squared up you can see all the spheres

5

u/adamthebread Feb 09 '22

NOW DO IT WITH A PERSPECTIVE CAMERA

4

u/tasty_plots Feb 09 '22

Unfortunately the effect only works with an orthographic camera

1

u/Heban Feb 09 '22

Hmm.. To appear as spheres in perspective, could they even be true spheres anymore?

5

u/adamthebread Feb 09 '22

why wouldn't they?

1

u/Heban Feb 09 '22

Well I was thinking about how objects in games sometimes look distorted the further from the center of your screen they are. And how objects closer to your eye appear bigger than distant objects of the same size.

If you want the objects to appear as spheres POST distortion then they would need to be warped in a way to offset that distortion.

I don’t know enough to confidently say that is an inherent property of perspective though. Just pondering your challenge.

0

u/skarloni Feb 09 '22

does spheres look like spheres to you in real life?

5

u/CFDMoFo Feb 08 '22

Damn that's black magic. How did you do it? Answer, or it'll be burning at the stake for you ;)

17

u/tasty_plots Feb 08 '22

I packed circles with the same radius twice. In the xy and yz planes. Then you rotate around the xyz spheres with an isographic camera

4

u/AngryGrenades Feb 09 '22

So so you do your first packing with two degrees of freedom per circle and your second with only one?

1

u/tasty_plots Feb 09 '22

Yes

2

u/Tomycj Feb 09 '22 edited Feb 09 '22

Did you place and ordered them by hand? Was it made in blender? edit: nevermind, its "Made in TouchDesigner with GLSL / Compute Shader"

1

u/tasty_plots Feb 09 '22

No, it's blender and they are positioned by python code. That touchdesigner one was someone recreating it

1

u/Tomycj Feb 09 '22

Oh really? Nice, thanks for correcting me. Are the spheres positioned so that there's a circumscribed cube around each one of them, where no other sphere pertrudes?

1

u/tasty_plots Feb 09 '22

Not a cube but none of them can intersect

2

u/gibl3t Feb 09 '22

this is amazing. I wish reddit didnt compress the ever loving crap out of it, because im sure it would look even better

1

u/tasty_plots Feb 09 '22

You can see it in full resolution uncompressed here https://objkt.com/asset/hicetnunc/665037

2

u/eskimopie910 Feb 09 '22

One of the coolest posts on here tbh

18

u/TorSkywalker Feb 08 '22

Very cool!

6

u/[deleted] Feb 09 '22

To me this is epic and anxiety inducing at the same time

It’s sick great job

1

u/mutsuto Feb 09 '22

repost?

3

u/tasty_plots Feb 09 '22

An improved version of something I posted previously

1

u/mutsuto Feb 09 '22

i dont see a difference, can you tell me the improvements?

3

u/AsmallDinosaur Feb 08 '22

Damn that's sick

1

u/all_is_love6667 Feb 09 '22

I think I can understand how the algorithm would work, but it's pretty neat!

1

u/[deleted] Nov 19 '22

Please master, do a tutorial