HOW MUCH CAN SIMPLE ENGINE HANDLE ??

Поделиться
HTML-код
  • Опубликовано: 27 янв 2025

Комментарии • 353

  • @Champignon1000
    @Champignon1000 3 года назад +1659

    It took a lot of balls to make this video.

    • @kaidatong1704
      @kaidatong1704 3 года назад +34

      many balls were used in the making of this video

    • @Champignon1000
      @Champignon1000 3 года назад +24

      @@kaidatong1704 Let's spend a week celebrating the balls of different orientation and color 🌈🏴

    • @explosifiy
      @explosifiy 3 года назад +14

      180000 to be exact

    • @Champignon1000
      @Champignon1000 3 года назад +9

      @@explosifiy How long did it take to count them?

    • @glngrbread6363
      @glngrbread6363 3 года назад +1

      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

  • @dELTA13579111315
    @dELTA13579111315 3 года назад +626

    This also shows crystal grain structure pretty well, really cool

    • @monad_tcp
      @monad_tcp 3 года назад +51

      first I though, a bit buggy, then I remembered, those defects also happens in nature, not a bug at all

    • @EliorFureraj15
      @EliorFureraj15 3 года назад +5

      @@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?

    • @AbsolutelyPlasmadic
      @AbsolutelyPlasmadic 3 года назад +23

      @@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_
      @capsey_ 3 года назад +7

      @@EliorFureraj15 there's a video about this ruclips.net/video/xuL2yT-B2TM/видео.html

    • @kaidatong1704
      @kaidatong1704 3 года назад +2

      @@capsey_ I got that within same recommendation section, almost next to this one. see screenshot for proof imgur.com/a/tp3G2UC

  • @Nukestarmaster
    @Nukestarmaster 3 года назад +283

    It's fascinating watching the waves propagating against the flow.

    • @MarcCastellsBallesta
      @MarcCastellsBallesta 3 года назад +18

      That's how traffic jams flow!

    • @TheRealFlenuan
      @TheRealFlenuan 3 года назад +20

      It's not accurate physics lmao

    • @kejith1004
      @kejith1004 3 года назад +19

      @@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.

    • @agvulpine
      @agvulpine 3 года назад +6

      @@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.

    • @Thesoorajtom
      @Thesoorajtom 3 года назад

      @@TheRealFlenuan These are the sames waves that cause this ? ruclips.net/video/DvtbQs7hWXw/видео.html

  • @teenspirit1
    @teenspirit1 3 года назад +390

    80k circle collisions in a respectable framerate well done! Maybe some of the computation can be batched and parallelized for additional speed.

    • @silvertakana3932
      @silvertakana3932 3 года назад +10

      Maybe he is using sleeping

    • @vailder
      @vailder 3 года назад +2

      CUDA/OpenCL/AMP - to help

    • @vailder
      @vailder 3 года назад +2

      But because he use SFML, he can use amp.h

    • @PezzzasWork
      @PezzzasWork  3 года назад +148

      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.

    • @roadkinggod
      @roadkinggod 3 года назад

      Imagine if he could also implement multi-threading support!

  • @kylaxial
    @kylaxial 3 года назад +208

    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

    • @skepticmafia
      @skepticmafia 3 года назад +1

      Good

    • @suwedo8677
      @suwedo8677 3 года назад +12

      What you are searching for is Hall of the Mountain King

    • @quack3891
      @quack3891 3 года назад

      @@suwedo8677 this is exactly what was playing in my head

    • @_CloudyBunny
      @_CloudyBunny 3 года назад +3

      It's called "Synesthesia".

    • @SirusStarTV
      @SirusStarTV 3 года назад +1

      @@suwedo8677 совершенно не то

  • @alexm7023
    @alexm7023 3 года назад +77

    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.

    • @katiebarber407
      @katiebarber407 3 года назад

      just noticed that. and it happens on like multiple levels afterward so cool

    • @SerBallister
      @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..

  • @danimadi3
    @danimadi3 3 года назад +37

    Dear Fellow Scholars, this is Two Minute Papers with Dr. Károly Zsolnai-Fehér.

  • @AAvfx
    @AAvfx 3 года назад +39

    Beautiful and satisfying!

  • @eltonrr1
    @eltonrr1 3 года назад +4

    3:44 is a moment when you can spot a kangaroo right there.

  • @suvidani
    @suvidani 3 года назад +61

    Looks good. Now shake it!

  • @yoavelbag4957
    @yoavelbag4957 3 года назад +16

    Amazing! It's not even close to number of atoms in a water drop!
    The Matrix has some serious computing power..

  • @XGD
    @XGD 3 года назад +1

    I like how this is an indirect simulation of imperfect crystal formation

  • @blackdragon3638
    @blackdragon3638 3 года назад +24

    You're supposed to watch this while listening to "In the hall of mountain king". Trust me, i tried it.

  • @c_1947
    @c_1947 4 года назад +28

    This video deserves more views

    • @LuciSheppyLive
      @LuciSheppyLive 3 года назад +4

      Well the algorithm caught onto it so here we go

    • @Vexinal
      @Vexinal 3 года назад

      @@LuciSheppyLive thats exactly what i was gonna say lol

  • @petersmythe6462
    @petersmythe6462 3 года назад +8

    Interesting watching the various types of waves and phase transitions.

  • @exel001
    @exel001 3 года назад +17

    2:06 that effect when some wave moves up against flow is very funny :) what is it ?

    • @PezzzasWork
      @PezzzasWork  3 года назад +14

      It's actually a bug when collision doesn't handle velocity update correctly resulting in the object moving in the wrong direction :D

    • @IvaHaze
      @IvaHaze 3 года назад +5

      @@PezzzasWork nice bug

  • @AlexTrusk91
    @AlexTrusk91 3 года назад +1

    1:30 thats a nice laminar flow right there. i also like how the "fluid" animation seems to get better with each step up

  • @wokafish249
    @wokafish249 3 года назад +2

    "Hey guys look a my rainbow balls"
    - youtube recommend page 2021

  • @yodayoda4137
    @yodayoda4137 3 года назад +1

    That looks like a water simulation in the end

  • @jachymecek
    @jachymecek 3 года назад +1

    youtube reccomended me this for no reason, but kinda satisfing tho.

    • @jachymecek
      @jachymecek 3 года назад +1

      @RUclips Algorithm oh poop

  • @enque01
    @enque01 3 года назад +1

    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.

  • @dromeosaur1031
    @dromeosaur1031 3 года назад +10

    Thank you! This is really inspiring.

  • @AhmedHan
    @AhmedHan 3 года назад +1

    Are you telling me 180k objects are iterated every 40ms along with a collision detection algorithm running for every single one?

  • @TheSuckerOfTheWorld
    @TheSuckerOfTheWorld 3 года назад +14

    Interesting how having an emitter active gives you an increased render time. See 0:16 when it goes up.

    • @thatotherandrew_
      @thatotherandrew_ 3 года назад +2

      I think that's due to having to perform trajectory calculations instead of just dropping the balls, that's just a guess though.

    • @theaveragepro1749
      @theaveragepro1749 3 года назад +1

      probably because it has to instantiate and create a whole bunch of new balls, though I haven't looked at the engine at all

    • @lm1338
      @lm1338 3 года назад

      It's vsync

    • @lm1338
      @lm1338 3 года назад +3

      @@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.

  • @konradburnett
    @konradburnett 2 года назад

    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.

  • @WryTrvr
    @WryTrvr 2 года назад

    That was like beautiful 3 dimensional water physics sometimes

  • @spearhead30
    @spearhead30 3 года назад

    That was a very helpful deconstructed video processing demonstration.

  • @felulaval4742
    @felulaval4742 3 года назад

    At the end I was waiting for the whole thing to be turned upside down

  • @gimmethedata4256
    @gimmethedata4256 3 года назад +2

    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.

  • @busy_beaver
    @busy_beaver 2 года назад

    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?

  • @christophergreeley4880
    @christophergreeley4880 3 года назад +1

    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

  • @Kian00
    @Kian00 3 года назад

    I never thought I’d witness a resinace cascade first hand

  • @Lb.q2
    @Lb.q2 3 года назад +1

    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 RUclips view count but how large is actually is

  • @anothrnoml
    @anothrnoml 3 года назад +4

    i did something like this in code bullet's marble calculator, it didn't go well on that old chromebook

  • @BirdTho
    @BirdTho 3 года назад

    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.

  • @susitu6609
    @susitu6609 2 года назад

    1 engine was harmed in the making of this video

  • @zebraforceone
    @zebraforceone Год назад

    That is incredible stability considering

  • @dnsbrules_01
    @dnsbrules_01 3 года назад +4

    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.

  • @donovanmahan2901
    @donovanmahan2901 3 года назад

    Wow the resulting structure actually has a temperature

  • @jasyak2
    @jasyak2 3 года назад +1

    Short answer: 180K
    Long answer: This video

  • @kalebbruwer
    @kalebbruwer 3 года назад +2

    That's pretty impressive. I assume you put some kind of optimizations into how static collisions are calculated?

  • @Nosikas
    @Nosikas 3 года назад

    This is so mesmerizing

  • @sciencedoneright
    @sciencedoneright 3 года назад

    Plot twist: this uses the collision system he was trying to make that time

  • @thecoolguy1233
    @thecoolguy1233 3 года назад

    If everything had a friction of zero would it act like a fluid?

  • @markoftheland3115
    @markoftheland3115 4 года назад +7

    That's pretty good! Have you compared it to box2d?

    • @PezzzasWork
      @PezzzasWork  4 года назад +11

      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.

    • @horowitzhill6480
      @horowitzhill6480 3 года назад

      @@PezzzasWork "assume 5000 pergectly cyclical massless zombies" 😁

  • @alephcake
    @alephcake 3 года назад

    if you would give them less friction it could be a realistic water simulation

  • @yudhistira7231
    @yudhistira7231 3 года назад

    but how did you handle that many collisions without any unacceptable lag?!? Amazing work dudee

  • @RedStinger_0
    @RedStinger_0 2 года назад

    end result is great album cover material

  • @auroralshine6176
    @auroralshine6176 3 года назад

    Frame time's gangsta unless he puts bunch of TNT's in there.

  • @HugoStuff
    @HugoStuff 3 года назад +1

    Money you make per second in idle games be like:

  • @bennysh
    @bennysh 3 года назад +1

    It's amazing, the power of today CPUs..

  • @angrywolfjr7164
    @angrywolfjr7164 3 года назад

    as an average SFML enjoyer, and still learning, i love this video

  • @agvulpine
    @agvulpine 3 года назад

    I call this limitation on simulated force propagation the "Turtles all the way down" problem.

  • @Alexander_Sannikov
    @Alexander_Sannikov 3 года назад

    is it position-based verlet? are you using shock propagation? it looks suspiciosly stable at the bottom.

  • @IdkwhymynamecantjustbeCody
    @IdkwhymynamecantjustbeCody 3 года назад

    This is how rock layers are formed.

  • @gabef9538
    @gabef9538 3 года назад

    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.

  • @akrickok3482
    @akrickok3482 3 года назад

    I was kinda hoping for a full-width barrage at the end, but cool video anyway!

  • @virdvird
    @virdvird 3 года назад

    There should be error in physics implementation. Balls didn't preserve energy correctly on hit. So you can see stream spread go up phenomenon, which should not be

  • @kedman1095
    @kedman1095 3 года назад +3

    will be perfect with "In the Hall of the Mountain King" music ^^

  • @Luke-mf6tg
    @Luke-mf6tg 3 года назад

    Could you put people on that land you created?

  • @mr2octavio
    @mr2octavio 3 года назад

    I would like to know what errors are in the engine

  • @Henrix1998
    @Henrix1998 3 года назад

    How on earth the physics time just stops growing?

  • @BossBeneBaby
    @BossBeneBaby 3 года назад

    Wow looks awesome! Just a quick question. Wouldn't it make sense to put all the the calculation inside a computeshader?

  • @unluckypanda5448
    @unluckypanda5448 3 года назад

    the thumbnail made me think it's powder toy

  • @MichaeltLoL
    @MichaeltLoL 4 года назад +3

    Would it be possible to get collision detection/response code?

    • @PezzzasWork
      @PezzzasWork  4 года назад +2

      Just added the repo in the description. The Github is a bit messy but you can find the collision detection and response code in include/access_grid.hpp and include/collision_solver.hpp

    • @MichaeltLoL
      @MichaeltLoL 4 года назад

      @@PezzzasWork thank you very much! I've tried to implement something similar myself but the collision response became buggy when i put ball on top of another for some reason

    • @PezzzasWork
      @PezzzasWork  4 года назад +5

      @@MichaeltLoL I've got the same kind of bugs tons of times while experimenting with physics. It's generally because the response is too high which leads to instability because energy is "created" . For this project in particular I used a very empirical approach with some "magic coefficients" that appeared to work fine. What also helps is to solve collisions multiple times, it can really absorb position correction overshoots which happen really often when you have a complex system with a lot of bodies. Honestly what I've learn from all my physic projects is that if you want to do things seriously, it is not that easy!

  • @starshipsn1013
    @starshipsn1013 3 года назад

    It looks like when you put a magnet up to a tv

  • @blackdragoncool
    @blackdragoncool 3 года назад +1

    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!

    • @PezzzasWork
      @PezzzasWork  3 года назад

      I am using a fixed grid and nothing special happens to static objects, my approach is very basic :)

    • @blackdragoncool
      @blackdragoncool 3 года назад

      @@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!

  • @MrSerozka
    @MrSerozka 3 года назад

    Why does render time lowers when number of balls increases?

  • @miranda.cooper
    @miranda.cooper 3 года назад

    What happens if you take away most of the friction? Like to the point it acts like water?

  • @Aresydatch
    @Aresydatch 3 года назад

    How can i compile this, Or is there a Pre compiled EXE?

  • @ruskyivanich2107
    @ruskyivanich2107 3 года назад

    I see you're using my favorite cereal kix as a demonstration

    • @ruskyivanich2107
      @ruskyivanich2107 3 года назад

      Oh wait it's more like cap'n crunch oops all berries

  • @abhay_more
    @abhay_more 3 года назад

    The final looks like Perlin noise

  • @MrGlockshna
    @MrGlockshna 3 года назад

    I wanted you to invert gravity at the end :(

  • @zashbot
    @zashbot 3 года назад

    you’re varying the color based on the number of the balls? the color changed slower in the beginning.

  • @entized5671
    @entized5671 3 года назад

    180000 objects
    GD creators: gotta crank those numbers up, those are rookie numbers

  • @arkhaic1792
    @arkhaic1792 3 года назад +1

    this is amazing
    someone make a physics based game out of this

    • @pashadanilov3490
      @pashadanilov3490 3 года назад

      You can try "The powder toy"

    • @arkhaic1792
      @arkhaic1792 3 года назад

      @@pashadanilov3490 oh yeah thats s childhood game

  • @Yukiyonova
    @Yukiyonova 3 года назад

    Everybody gangsta till the wall starts peeing

  • @eco1969
    @eco1969 Год назад

    Great example of sedimentary deposits over time

  • @Pinupopinion
    @Pinupopinion 3 года назад

    Ok now add a function where she loves me back

  • @estebans9110
    @estebans9110 3 года назад

    why does render time go faster with more balls?

  • @vmened
    @vmened 3 года назад +2

    Damn, i want to read your code). How i can do that in java?

    • @cyberflixt
      @cyberflixt 3 года назад +2

      No way, it's too slow.
      I guess it's a C(#/++) engine

    • @homelikebrick42
      @homelikebrick42 3 года назад

      Cyberflix C++

  • @priuxls
    @priuxls 3 года назад +1

    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👍🏻👍🏻

    • @vibaj16
      @vibaj16 3 года назад

      You have to be careful though. Sometimes that type of optimization can lead to some not being updated when they should be getting updated

    • @priuxls
      @priuxls 3 года назад

      @@vibaj16 Yes, I think a conservative approach to creating the importance map is key👍🏻

  • @Mark00747
    @Mark00747 3 года назад

    Could you please add the solution file to the Github? I don't know how to open it

  • @alejandroalzatesanchez
    @alejandroalzatesanchez 3 года назад

    How gtx particle system can be .-.

  • @Kinetic_CGI
    @Kinetic_CGI 3 года назад

    Why did I hear my computer fans kick up when I started playing this video?

  • @TheFloatingSheep
    @TheFloatingSheep 3 года назад

    Damn, it barely made a dent in the performance until that second waterfall showed up, and even then it stayed above what'd convert to 30fps

    • @dayone3363
      @dayone3363 3 года назад

      Frame time doesnt mean fps it isnt the same 30 ms frame time is something arround 10 fps

    • @TheFloatingSheep
      @TheFloatingSheep 3 года назад

      @@dayone3363 I'm aware, I calculated the fps
      40ms per frame comes in at about 25fps because 40ms fit 25 times in a second.

    • @vibaj16
      @vibaj16 3 года назад

      Timur Begach No, that would be around 3 fps

  • @Lol-pz9ow
    @Lol-pz9ow 3 года назад

    Bit rate does BRRRRR

  • @vwr0527
    @vwr0527 3 года назад

    How do you use multithreading? Like how is the work divided up, then re-integrated?

  • @AllExistence
    @AllExistence Год назад

    The fact that they don't move down and stay clumped at the side means that there is plenty of optimization going on on behalf of realism.

  • @126sivgucsivanshgupta2
    @126sivgucsivanshgupta2 3 года назад

    how does render time decrease ?

  • @Jake629
    @Jake629 3 года назад

    pretty colours

  • @Wolfoxy1904
    @Wolfoxy1904 3 года назад

    my pc would die at the second ball

  • @sourcelocation
    @sourcelocation 3 года назад

    Awesome video! How do you compile the project?

  • @ducking_fonkey
    @ducking_fonkey 3 года назад

    My physics engine would start to lag at around this moment 0:45 and of course I made it in LuaU.

  • @cantstopthis1123
    @cantstopthis1123 3 года назад +1

    this is gonna blow up

  • @Tiniuc
    @Tiniuc 3 года назад +3

    I want to play around with this so much right now

  • @AiOinc1
    @AiOinc1 3 года назад +1

    This is just a free particle engine at this point. Kinda neat to see as you zoom out how much more liquid like it acts
    I think you might be able to improve on that physics time by implementing something like settle detection, which would recognize when the object is no longer being acted upon by any forces and stops calculating it's position. This might drastically reduce the amount of time to calculate physics and the amount of object jitter.

  • @ka-md8ue
    @ka-md8ue 3 года назад

    What's the difference between render time and frame time?

    • @thomasstambaugh5181
      @thomasstambaugh5181 3 года назад

      I assume that "render" time is the amount of time rendering the scene, "physics time" is the amount of time computing the features to render, and "frame time" is gross time per frame. The frame time was stable at 16 msec for awhile -- that's an interesting number because anything faster than 16.7 msec isn't visible on a monitor with a 60hz refresh rate.

  • @rpyrat
    @rpyrat 3 года назад +1

    What rule did you use to color the balls?

    • @PezzzasWork
      @PezzzasWork  3 года назад +3

      I am using 255*sin(0.001 * i + 2pi / 3 * k)^2 with i being the index of the object and k the index of the color component (r 0, g 1, b 2)

  • @0hate9
    @0hate9 3 года назад +1

    I wonder what those numbers would look like if these were squares lol