Multithreaded (CPU only) version of my Simple Engine written in C++ and using SFML for graphics. Running on a i5 7300hq and a GTX 1060. Recording decreased performance by ~20%. Github github.com/johnBuffer/UnitedE...
Пікірлер: 353
@Champignon10003 жыл бұрын
It took a lot of balls to make this video.
@kaidatong17043 жыл бұрын
many balls were used in the making of this video
@Champignon10003 жыл бұрын
@@kaidatong1704 Let's spend a week celebrating the balls of different orientation and color 🌈🏴
@explosify50353 жыл бұрын
180000 to be exact
@Champignon10003 жыл бұрын
@@explosify5035 How long did it take to count them?
@glngrbread63633 жыл бұрын
I wonder if you could make a more accurate simulation of water by applying a constant force back and forth on the balls so they wiggle a lil
@dELTA135791113153 жыл бұрын
This also shows crystal grain structure pretty well, really cool
@monad_tcp3 жыл бұрын
first I though, a bit buggy, then I remembered, those defects also happens in nature, not a bug at all
@EliorFureraj153 жыл бұрын
@@monad_tcp Hello, sorry to bother you, but what do you mean by that? Are the defects the empty lines between circles at the end? And what are you referring to when you say it happens in nature too?
@AbsolutelyPlasmadic3 жыл бұрын
@@EliorFureraj15 I'm not too well read on the subject. but I believe they are speaking of how the balls naturally fall into a perfect tesselation, however between the large clumps are empty spaces. and in nature, crystal structures form these sort of semi-perfect tesselations that don't always perfectly fit together. lmk if I helped at all, and if not I'd love to try and explain it a bit more :)
@capsey_3 жыл бұрын
@@EliorFureraj15 there's a video about this kzbin.info/www/bejne/rqavY6yKYqdliq8
@kaidatong17043 жыл бұрын
@@capsey_ I got that within same recommendation section, almost next to this one. see screenshot for proof imgur.com/a/tp3G2UC
@Nukestarmaster3 жыл бұрын
It's fascinating watching the waves propagating against the flow.
@MarcCastellsBallesta3 жыл бұрын
That's how traffic jams flow!
@TheRealFlenuan3 жыл бұрын
It's not accurate physics lmao
@kejith10043 жыл бұрын
@@TheRealFlenuan I was thinking the same thing with propagating against the flow. It can fascinate you without beeing accurate. It's just a fun thing to think about.
@agvulpine3 жыл бұрын
@@TheRealFlenuan it's only inaccurate because the engine can't cope with granting infinite force propagation beyond n particles from the initial collision, such that the original particle must assume there's a solid floor somewhere beneath it, and now gravity goes out the window. "Turtles all the way down" should become the textbook name of this problem. Feel free to use it.
@Thesoorajtom3 жыл бұрын
@@TheRealFlenuan These are the sames waves that cause this ? kzbin.info/www/bejne/eqfXk4SpbM2Kjtk
@kylaxial3 жыл бұрын
for some reason, when I watched the video, I imagined orchestra music playing in my head that got higher in pitch every time you increase the circle drop rate
@skepticmafia3 жыл бұрын
Good
@suwedo86773 жыл бұрын
What you are searching for is Hall of the Mountain King
@quack38913 жыл бұрын
@@suwedo8677 this is exactly what was playing in my head
@_CloudyBunny3 жыл бұрын
It's called "Synesthesia".
@SirusStarTV3 жыл бұрын
@@suwedo8677 совершенно не то
@teenspirit13 жыл бұрын
80k circle collisions in a respectable framerate well done! Maybe some of the computation can be batched and parallelized for additional speed.
@silvertakana39323 жыл бұрын
Maybe he is using sleeping
@vailder3 жыл бұрын
CUDA/OpenCL/AMP - to help
@vailder3 жыл бұрын
But because he use SFML, he can use amp.h
@PezzzasWork3 жыл бұрын
It's parallelized using a threads pool library I made. But it's far from perfect, there are some bugs and the threads workload isn't very well balanced.
@roadkinggod3 жыл бұрын
Imagine if he could also implement multi-threading support!
@alexm70233 жыл бұрын
2:00 I like that shock wave that traveled backward. I remembered there is a similar phenomenon in trans-sonic flow. Been a while since i took fluid dynamic.
@clown1343 жыл бұрын
just noticed that. and it happens on like multiple levels afterward so cool
@SerBallister Жыл бұрын
I've played around with these before, you see a different kinds of fluid dynamics in these systems, you can drag large objects through it and it'll simulate the vacuum area that gets dragged behind it along with the turbulence you would expect... All that from simple repulsive balls..
@suvidani3 жыл бұрын
Looks good. Now shake it!
@eltonrr13 жыл бұрын
3:44 is a moment when you can spot a kangaroo right there.
@yoavelbag49573 жыл бұрын
Amazing! It's not even close to number of atoms in a water drop! The Matrix has some serious computing power..
@DontWatchAdsJustRefresh Жыл бұрын
It just goes
@dradex9562 Жыл бұрын
...The matrix
@danimadi33 жыл бұрын
Dear Fellow Scholars, this is Two Minute Papers with Dr. Károly Zsolnai-Fehér.
@bobthebuilder54933 жыл бұрын
😂
@blackdragon36383 жыл бұрын
You're supposed to watch this while listening to "In the hall of mountain king". Trust me, i tried it.
@unluckypanda54483 жыл бұрын
youre right lol
@petersmythe64623 жыл бұрын
Interesting watching the various types of waves and phase transitions.
@c_19473 жыл бұрын
This video deserves more views
@LuciSheppy3 жыл бұрын
Well the algorithm caught onto it so here we go
@Vexinal3 жыл бұрын
@@LuciSheppy thats exactly what i was gonna say lol
@dromeosaur10313 жыл бұрын
Thank you! This is really inspiring.
@AAvfx3 жыл бұрын
Beautiful and satisfying!
@raiseddd3 жыл бұрын
Okay
@spearhead303 жыл бұрын
That was a very helpful deconstructed video processing demonstration.
@enque013 жыл бұрын
Omg i didn't expect such a simple simulation to produce actual crystal grain structures identical to real materials. Including correctly simulated point imperfections and lattice faultlines! Suuuuuper cool! Ive only seen this in textbooks before, but not animated. The point imperfections were actually even flickering in this simulation, bringing them out even more! Also very interesting that there was a certain average size to the grains produced.
@XGD3 жыл бұрын
I like how this is an indirect simulation of imperfect crystal formation
@Nosikas3 жыл бұрын
This is so mesmerizing
@konradburnett688 Жыл бұрын
you could see a well-established crystal structure near the beginning and molecular skips in the lattice causing all of the worm like lines travelling about.
@RolandOrre3 жыл бұрын
Great job❣
@zebraforceone Жыл бұрын
That is incredible stability considering
@jomy10-games3 жыл бұрын
That’s impressive!
@wokafish2493 жыл бұрын
"Hey guys look a my rainbow balls" - youtube recommend page 2021
@guilhermealveslopes3 жыл бұрын
Quite awesome!
@christophergreeley48803 жыл бұрын
Found it interesting how the render time kept going down as physics time increased, even when you zoomed out/in. Also you should have gone to the millions :P
@kalebbruwer3 жыл бұрын
That's pretty impressive. I assume you put some kind of optimizations into how static collisions are calculated?
@cantstopthis11233 жыл бұрын
this is gonna blow up
@dnsbrules_013 жыл бұрын
This is a really nice simulation of objects generation on your computer, molecular structures, and hexagons. You can see the granules of the structure move as it grows slowly but at the end where they grew fast they are small. And hexagons because when there’s a gap between a bunch it stays till the weight of the one above it collapses it.
@BossBeneBaby3 жыл бұрын
Wow looks awesome! Just a quick question. Wouldn't it make sense to put all the the calculation inside a computeshader?
@angrywolfjr71643 жыл бұрын
as an average SFML enjoyer, and still learning, i love this video
@MarcCastellsBallesta3 жыл бұрын
I love it!
@gimmethedata42563 жыл бұрын
damn I am really impressed. I probably couldn't even run 1/10000 of that using my code before my computer would explode. This is so fast.
@thegamingdeath1232 жыл бұрын
it looks nice
@kedman10953 жыл бұрын
will be perfect with "In the Hall of the Mountain King" music ^^
@Jake6293 жыл бұрын
pretty colours
@WryTrvr Жыл бұрын
That was like beautiful 3 dimensional water physics sometimes
@yodayoda41373 жыл бұрын
That looks like a water simulation in the end
@sourcelocation3 жыл бұрын
Awesome video! How do you compile the project?
@turlupouet Жыл бұрын
Love it
@RedStinger_0 Жыл бұрын
end result is great album cover material
@anothrnoml3 жыл бұрын
i did something like this in code bullet's marble calculator, it didn't go well on that old chromebook
@Kian003 жыл бұрын
I never thought I’d witness a resinace cascade first hand
@cleanlens3 жыл бұрын
youtube reccomended me this for no reason, but kinda satisfing tho.
@cleanlens3 жыл бұрын
@KZbin Algorithm oh poop
@yudhistira72313 жыл бұрын
but how did you handle that many collisions without any unacceptable lag?!? Amazing work dudee
@felulaval47423 жыл бұрын
At the end I was waiting for the whole thing to be turned upside down
@Alexander_Sannikov3 жыл бұрын
is it position-based verlet? are you using shock propagation? it looks suspiciosly stable at the bottom.
@Tiniuc3 жыл бұрын
I want to play around with this so much right now
@exel0013 жыл бұрын
2:06 that effect when some wave moves up against flow is very funny :) what is it ?
@PezzzasWork3 жыл бұрын
It's actually a bug when collision doesn't handle velocity update correctly resulting in the object moving in the wrong direction :D
@IvaHaze3 жыл бұрын
@@PezzzasWork nice bug
@akrickok34823 жыл бұрын
I was kinda hoping for a full-width barrage at the end, but cool video anyway!
@ruskyivanich21073 жыл бұрын
I see you're using my favorite cereal kix as a demonstration
@ruskyivanich21073 жыл бұрын
Oh wait it's more like cap'n crunch oops all berries
@typicalhog3 жыл бұрын
Insane!
@blackdragoncool3 жыл бұрын
Would love to know more about the implementation, making a particle sim myself. What spatial partition methods did you use? Did you have a system to stop ticking entities which weren't moving above a given threshold? Thanks!
@PezzzasWork3 жыл бұрын
I am using a fixed grid and nothing special happens to static objects, my approach is very basic :)
@blackdragoncool3 жыл бұрын
@@PezzzasWork Always great to find down to earth implementations that just work well! I'm not very familiar with C++ so I have a harder time parsing the source which is why I asked, thanks for the reply! I've been using a Octree myself but I'm finding difficulty inserting entities in a way that spatially proximate entities will also be close in memory as to reduce cache misses... maybe I should have started with a grid!
@gabef95383 жыл бұрын
It is strange that the deep(defined by zone, density, and relative inactivity) parts aren't forced to settle and change into a pasive state until a neighboring zone is agitated.
@donovanmahan29013 жыл бұрын
Wow the resulting structure actually has a temperature
@Sciencedoneright3 жыл бұрын
Plot twist: this uses the collision system he was trying to make that time
@vwr05273 жыл бұрын
How do you use multithreading? Like how is the work divided up, then re-integrated?
@miranda.cooper3 жыл бұрын
What happens if you take away most of the friction? Like to the point it acts like water?
@UserName-ik9qm3 жыл бұрын
i like the sound
@BirdTho3 жыл бұрын
Looks like the engine couldn't keep up and there was interpenetration especially at the larger 'flow' sizes where there was a reverse wave travelling back up the stream.
@Mark007473 жыл бұрын
Could you please add the solution file to the Github? I don't know how to open it
@abhay_more3 жыл бұрын
The final looks like Perlin noise
@IdkwhymynamecantjustbeCody3 жыл бұрын
This is how rock layers are formed.
@bluethumbbuttoneek94653 жыл бұрын
Now that's alotta balls
@gdgames95853 жыл бұрын
Owo new skittles ad?
@Lol-pz9ow3 жыл бұрын
Bit rate does BRRRRR
@mr2octavio3 жыл бұрын
I would like to know what errors are in the engine
@markoftheland31154 жыл бұрын
That's pretty good! Have you compared it to box2d?
@PezzzasWork4 жыл бұрын
I did not try to compare but I'm sure on the performance it's way faster because it's very basic. It jus handles circle - circle collisions. I made it for massive and inaccurate scenario like an army of zombies.
Frame time's gangsta unless he puts bunch of TNT's in there.
@MrBallL0L Жыл бұрын
Proud to be in the video 👍
@Aresydatch3 жыл бұрын
How can i compile this, Or is there a Pre compiled EXE?
@agvulpine3 жыл бұрын
I call this limitation on simulated force propagation the "Turtles all the way down" problem.
@susitu66092 жыл бұрын
1 engine was harmed in the making of this video
@thecoolguy12333 жыл бұрын
If everything had a friction of zero would it act like a fluid?
@eco1969 Жыл бұрын
Great example of sedimentary deposits over time
@Luke-mf6tg3 жыл бұрын
Could you put people on that land you created?
@Ur_N0.1_fan3 жыл бұрын
Hewwo mister ObamA? HEWWOOoo?!
@unluckypanda54483 жыл бұрын
the thumbnail made me think it's powder toy
@priuxls3 жыл бұрын
I have seen an approach to optimize such problems. All the balls in the "crustal structure" which are not moving don't need to be updated. It's possible to create an importance map of all the balls and update them accordingly. But either way your engine is pretty good👍🏻👍🏻
@vibaj163 жыл бұрын
You have to be careful though. Sometimes that type of optimization can lead to some not being updated when they should be getting updated
@priuxls3 жыл бұрын
@@vibaj16 Yes, I think a conservative approach to creating the importance map is key👍🏻
@126sivgucsivanshgupta22 жыл бұрын
how does render time decrease ?
@TheSuckerOfTheWorld3 жыл бұрын
Interesting how having an emitter active gives you an increased render time. See 0:16 when it goes up.
@thatotherandrew_3 жыл бұрын
I think that's due to having to perform trajectory calculations instead of just dropping the balls, that's just a guess though.
@theaveragepro17493 жыл бұрын
probably because it has to instantiate and create a whole bunch of new balls, though I haven't looked at the engine at all
@lm13383 жыл бұрын
It's vsync
@lm13383 жыл бұрын
@@waldolemmer The increased render time is just waiting for the screen refresh. Notice how it's glued to a 16ms total frame time (60fps) even as the sim time increases. If you look at the code, you can see that the key "E" on the keyboard is bound to both creating an emitter and to enabling vsync. It has nothing to do with trajectories (they were always being calculated) and it has nothing to do with instantiating anything.
@AhmedHan3 жыл бұрын
Are you telling me 180k objects are iterated every 40ms along with a collision detection algorithm running for every single one?
@HugoStuff3 жыл бұрын
Money you make per second in idle games be like:
@CSDragon3 жыл бұрын
how did the render time go down as the number of objects went up?
@elorrambasdo52333 жыл бұрын
The render time was trying to stabilize the frame rate.
@busy_beaver2 жыл бұрын
What's that strange wave of a strange mess going upwards the right flow of balls between 2:35 and 2:52 , then going down?
@arkhaic17923 жыл бұрын
this is amazing someone make a physics based game out of this
@pashadanilov34903 жыл бұрын
You can try "The powder toy"
@arkhaic17923 жыл бұрын
@@pashadanilov3490 oh yeah thats s childhood game
@cakedon3 жыл бұрын
if you would give them less friction it could be a realistic water simulation
@atlasua20213 жыл бұрын
Multithreading or GPU? Very cool! I also want to write my own physics engine, only using a shader. - Очень круто! Я также хочу написать свой собственный физический движок, только используя шейдер.
@Pinupopinion3 жыл бұрын
Ok now add a function where she loves me back
@MrSerozka3 жыл бұрын
Why does render time lowers when number of balls increases?
@Wolfoxy19042 жыл бұрын
my pc would die at the second ball
@soup-not-edible3 жыл бұрын
WHAT GPU / CPU DO YOU HAVE
@AHSEN.3 жыл бұрын
cooool
@jasyak23 жыл бұрын
Short answer: 180K Long answer: This video
@themihanoid50203 жыл бұрын
I want (and need) it
@Henrix19983 жыл бұрын
How on earth the physics time just stops growing?
@darkfrei23 жыл бұрын
Are collisions cached?
@Lb.q23 жыл бұрын
1:51 is the view count for this video for when I’m watching. Crazy to think each ball represents one of us watching. How 44,000 views seems relatively low for a KZbin view count but how large is actually is