100 000 Planets Gravity Simulation

  Рет қаралды 14,622

Spleesh

Spleesh

Күн бұрын

Пікірлер: 50
@Spleeshmi
@Spleeshmi 2 жыл бұрын
If anyone wants to see the latest version of this simulation it looks like this: kzbin.info/www/bejne/h17HaKZsmLSVntk Also, if people are interested, I wouldn't mind doing a live stream on twitch some time going through my code and explaining things.
@tulpamedia
@tulpamedia 2 жыл бұрын
Oh hell yes! I'm kind of an amateur physicist and I've been trying to simulate certain things like nbody sims, fluid motion, etc... but unfortunately I'm not the best programmer so it always comes out really unoptimized, slow and just not that good all around haha. I would love to see your process this simulation is impressive!
@justinanderson267
@justinanderson267 2 жыл бұрын
Can you do this with a sphere (the sun)?
@Europa_Forever
@Europa_Forever 2 жыл бұрын
I like how eventually it ends up looking like many galaxies expanding away from the center of it all
@tulpamedia
@tulpamedia 2 жыл бұрын
Wow this is amazing! I've built my own n-body simulation as well, but I haven't been able to get it this good yet hahaha
@VercilJuan
@VercilJuan 2 жыл бұрын
Damn bro this is... beautiful.
@curb-e7736
@curb-e7736 2 жыл бұрын
We're just a millisecond long scene in the universe.
@notaninterestingperson5769
@notaninterestingperson5769 2 жыл бұрын
Then let’s make it one whoever’s watching would want to replay again
@Kill_God
@Kill_God 2 жыл бұрын
Not even that long, but as the wise sir above me said, we can make it the most beautiful instant in the history of everything
@anondude6361
@anondude6361 2 жыл бұрын
Beautiful
@shubhsrivastava4417
@shubhsrivastava4417 Жыл бұрын
It became an elliptical galaxy!
@_LuisFernandes_
@_LuisFernandes_ 2 жыл бұрын
this is based on a OneLoneCoder project ? And are the pixels projected or simply computed in 2d ? great video and project :)
@Spleeshmi
@Spleeshmi 2 жыл бұрын
I used the olcPixelGameEngine for this version of the project. I have since moved to OpenGL though. The pixels are computed in 2D (with OpenCL). The physics can get a little more complex in 3D and I'm less confident in my ability to make a realistic algorithm at that level. Here is the current github project if you're interested: github.com/Spleeshmicannon/50-000-Planets-OpenCL-glfw3. I'm considering rendering it to an mp4 directly with OpenGL so I can upload it but idk.
@_LuisFernandes_
@_LuisFernandes_ 2 жыл бұрын
@@Spleeshmi I'm impressed by the fluidity of the simulation with so many particles, I'm trying to integrate barnes hut and do multithreading so I understand the difficulties you had to go through, even in 2d. I'll take a look at the github, thanks for sharing :)
@matejsteinhauser3974
@matejsteinhauser3974 2 жыл бұрын
Looks like a Galaxy ❤️✨🌀
@DescendDab
@DescendDab 2 жыл бұрын
I love it, good job :)
@reddrift3022
@reddrift3022 2 жыл бұрын
This is cool haha
@Spleeshmi
@Spleeshmi 2 жыл бұрын
thx
@halihammer
@halihammer 2 жыл бұрын
Wow! 100,000 particles is quite a number. How long did it take to render? And do all particles act on all others, or is there a distance-dependent limit where forces from distant particles are not considered?
@Spleeshmi
@Spleeshmi 2 жыл бұрын
All particles act on all others, even if the leave the frame. Also, your watching a screen recording, so it took as long to render as it took you to watch it.
@halihammer
@halihammer 2 жыл бұрын
@@Spleeshmi Very impressive speed. Have you written it in C?
@Spleeshmi
@Spleeshmi Жыл бұрын
@@halihammer C++
@SumofluffyVIDS
@SumofluffyVIDS 2 жыл бұрын
What is the music? It sounds so familiar.
@SumofluffyVIDS
@SumofluffyVIDS 2 жыл бұрын
@saschava Thanks! And I realized it sounded familiar because it's in Godzilla! :D
@Adamzki55555
@Adamzki55555 2 жыл бұрын
what programming olanguage do you use to make these simulations
@HoloDoctor90
@HoloDoctor90 2 жыл бұрын
c++ i guess
@Spleeshmi
@Spleeshmi 2 жыл бұрын
Yeah C++, and I used the OlcPixelGameEngine
@blissful4992
@blissful4992 2 жыл бұрын
How are you able to get it this smooth and in real time of 100k particles with a brute-force approach?
@Spleeshmi
@Spleeshmi 2 жыл бұрын
tldr: parallelisation (on the GPU) OpenCL does computation on the graphics card. The data is then passed from OpenCL directly to OpenGL. My graphics card also has over 1500 cuda cores. So thats effectively 1500 planet positions that can be computed in parallel or 1500 parallel operations per clock cycle (although I think its a little more complicated than that). For anyone wanting to execute this approach, I'd recommend using OpenGL compute kernels or CUDA since OpenCL is really painful to use though. I should also mention that the video here, doesn't use OpenGL but the current version of the project does. The video here is still passing the data back to ram and then sending it to the GPU for rendering. If you have a solid clock speed and good SIMD support on your CPU you may have more speed with that approach. This is a lot harder than what I did though since you have to manually sort that data into arrays that fit in each SIMD register and such.
@b.s.7693
@b.s.7693 2 жыл бұрын
Why are some planets pushed out of the array initially?
@Bossman50.
@Bossman50. 2 жыл бұрын
0:44 under armor
@enantiodromia
@enantiodromia Жыл бұрын
Reminds me of the game of life.
@blissful4992
@blissful4992 2 жыл бұрын
Hello, for the physics, why do you do fx += (-F * rx), shouldn't it be fx += (rx/sqrt(rx^2 + ry^2)) * -F because first you normalize the vector's x dimension and then you multiply by the force? I guess I just don't get why you are multiplying by the differences in x
@Spleeshmi
@Spleeshmi 2 жыл бұрын
The honest answer is I wrote that specific algorithm over a year ago and so I don't remember super well. I did speak to someone with more physics knowledge than I and they referred me to some equations which would help me make it fast. The other thing is a square root is really slow. I'd frankly do anything to avoid it and may have overlooked a mistake as a result. Thanks for taking the time to look at my algorithm, I'll revisit this and double check everything. EDIT: also, if you want to change the algorithm and see what happens you should be able to edit the .cl file in the prebuilt binaries folder and then just run the exe. The exe will only work on windows though and your graphics card will have to support OpenCL which it should, but might not.
@blissful4992
@blissful4992 2 жыл бұрын
@@Spleeshmi it’s true that just multiplying the force and the difference doesn’t give the same result but does vastly increase performance. Especially on the long term when you do ~n^2 force calculations for n bodies
@usptact
@usptact 2 жыл бұрын
100,000 rogue planets doing rogue planet things…
@scottbilger9294
@scottbilger9294 2 жыл бұрын
That's an marvelous rendition of Clair de Lune. Who is playing, I wonder?
@charlizesakura4468
@charlizesakura4468 Жыл бұрын
I think they could eventually form a Sun cus all the mass and Density And solar systems between them
@delawarepilot
@delawarepilot 2 жыл бұрын
What I expected when I bought universe sandbox.
@bobadingo
@bobadingo 2 жыл бұрын
So the model is based on a flat one dimension rectangle shape of 100,000 planets?
@Spleeshmi
@Spleeshmi 2 жыл бұрын
the planets are uniformly distributed across the shape but yeah, basically
@Lax3n
@Lax3n 2 жыл бұрын
with the general relativity theorem or the Newton one?
@Spleeshmi
@Spleeshmi 2 жыл бұрын
Newton, and not technically accurate as well, I need to normalize a vector apparently 🙄
@kazimierzmarkiel5400
@kazimierzmarkiel5400 2 жыл бұрын
Your galactic is not rotating- it is not naturally observed behaviour. Stary
@Spleeshmi
@Spleeshmi 2 жыл бұрын
If you want to take a look at the algorithm I use it's in the .cl file: github.com/Spleeshmicannon/50-000-Planets-OpenCL-glfw3
@davidstirling7992
@davidstirling7992 Жыл бұрын
Are these simulations supposed to accurately to describe reality?
@augustusmd
@augustusmd 2 жыл бұрын
did they collide?
@Spleeshmi
@Spleeshmi 2 жыл бұрын
no I'm not taking collisions into account, just gravity
@Frydekilde
@Frydekilde 2 жыл бұрын
They shape like X chromosomes and DNA. Interesting.
@sirave6017
@sirave6017 2 жыл бұрын
It looks like chromosomes but not connected correctly.
Journey to the Edge of the Universe in Real Time!
21:35
Astrobiscuit
Рет қаралды 398 М.
LAVROV's interview with Tucker CARLSON 😁 [Parody]
8:34
Юрий ВЕЛИКИЙ
Рет қаралды 281 М.
If people acted like cats 🙀😹 LeoNata family #shorts
00:22
LeoNata Family
Рет қаралды 41 МЛН
Don’t Choose The Wrong Box 😱
00:41
Topper Guild
Рет қаралды 50 МЛН
Gravity Simulation
5:24
JOrbits
Рет қаралды 18 М.
Can You Make Magnets Orbit Each Other?
8:46
The Action Lab
Рет қаралды 1,3 МЛН
I never understood why you can't go faster than light - until now!
16:40
FloatHeadPhysics
Рет қаралды 4,6 МЛН
Falling Into Jupiter (Simulation)
5:04
Stargaze
Рет қаралды 4,2 МЛН
3 Body Problem - Periodic Solutions
5:53
Matthew Sheen
Рет қаралды 119 М.
Simulation of galaxy formation
4:24
Takayuki Saitoh
Рет қаралды 162 М.
Black Hole's Evil Twin - Gravastars Explained
13:33
Kurzgesagt – In a Nutshell
Рет қаралды 3,2 МЛН