HOW MUCH CAN SIMPLE ENGINE HANDLE ??

Sdílet
Vložit
  • čas přidán 30. 05. 2019
  • 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...
  • Věda a technologie

Komentáře • 353

  • @Champignon1000
    @Champignon1000 Před 3 lety +1650

    It took a lot of balls to make this video.

    • @kaidatong1704
      @kaidatong1704 Před 3 lety +34

      many balls were used in the making of this video

    • @Champignon1000
      @Champignon1000 Před 3 lety +24

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

    • @explosify5035
      @explosify5035 Před 3 lety +14

      180000 to be exact

    • @Champignon1000
      @Champignon1000 Před 3 lety +9

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

    • @glngrbread6363
      @glngrbread6363 Před 3 lety +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 Před 3 lety +622

    This also shows crystal grain structure pretty well, really cool

    • @monad_tcp
      @monad_tcp Před 3 lety +51

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

    • @EliorFureraj15
      @EliorFureraj15 Před 3 lety +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 Před 3 lety +22

      @@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_ Před 3 lety +7

      @@EliorFureraj15 there's a video about this czcams.com/video/xuL2yT-B2TM/video.html

    • @kaidatong1704
      @kaidatong1704 Před 3 lety +2

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

  • @Nukestarmaster
    @Nukestarmaster Před 3 lety +283

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

    • @MarcCastellsBallesta
      @MarcCastellsBallesta Před 3 lety +18

      That's how traffic jams flow!

    • @TheRealFlenuan
      @TheRealFlenuan Před 3 lety +20

      It's not accurate physics lmao

    • @kejith1004
      @kejith1004 Před 3 lety +18

      @@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 Před 3 lety +5

      @@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 Před 3 lety

      @@TheRealFlenuan These are the sames waves that cause this ? czcams.com/video/DvtbQs7hWXw/video.html

  • @kylaxial
    @kylaxial Před 3 lety +206

    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 Před 3 lety +1

      Good

    • @suwedo8677
      @suwedo8677 Před 3 lety +12

      What you are searching for is Hall of the Mountain King

    • @quack3891
      @quack3891 Před 3 lety

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

    • @_CloudyBunny
      @_CloudyBunny Před 3 lety +3

      It's called "Synesthesia".

    • @SirusStarTV
      @SirusStarTV Před 3 lety +1

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

  • @teenspirit1
    @teenspirit1 Před 3 lety +389

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

    • @silvertakana3932
      @silvertakana3932 Před 3 lety +10

      Maybe he is using sleeping

    • @vailder
      @vailder Před 3 lety +2

      CUDA/OpenCL/AMP - to help

    • @vailder
      @vailder Před 3 lety +2

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

    • @PezzzasWork
      @PezzzasWork  Před 3 lety +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 Před 3 lety

      Imagine if he could also implement multi-threading support!

  • @alexm7023
    @alexm7023 Před 3 lety +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.

    • @clown134
      @clown134 Před 3 lety

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

    • @SerBallister
      @SerBallister Před rokem

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

  • @suvidani
    @suvidani Před 3 lety +59

    Looks good. Now shake it!

  • @yoavelbag4957
    @yoavelbag4957 Před 3 lety +16

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

  • @eltonrr1
    @eltonrr1 Před 3 lety +2

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

  • @danimadi3
    @danimadi3 Před 3 lety +37

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

  • @c_1947
    @c_1947 Před 3 lety +28

    This video deserves more views

    • @LuciSheppy
      @LuciSheppy Před 3 lety +4

      Well the algorithm caught onto it so here we go

    • @Vexinal
      @Vexinal Před 3 lety

      @@LuciSheppy thats exactly what i was gonna say lol

  • @petersmythe6462
    @petersmythe6462 Před 3 lety +8

    Interesting watching the various types of waves and phase transitions.

  • @blackdragon3638
    @blackdragon3638 Před 3 lety +25

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

  • @XGD
    @XGD Před 3 lety +1

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

  • @spearhead30
    @spearhead30 Před 3 lety

    That was a very helpful deconstructed video processing demonstration.

  • @dromeosaur1031
    @dromeosaur1031 Před 3 lety +10

    Thank you! This is really inspiring.

  • @enque01
    @enque01 Před 3 lety +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.

  • @AAvfx
    @AAvfx Před 3 lety +39

    Beautiful and satisfying!

  • @wokafish249
    @wokafish249 Před 3 lety +2

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

  • @Nosikas
    @Nosikas Před 3 lety

    This is so mesmerizing

  • @christophergreeley4880
    @christophergreeley4880 Před 3 lety +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

  • @zebraforceone
    @zebraforceone Před rokem

    That is incredible stability considering

  • @RolandOrre
    @RolandOrre Před 3 lety

    Great job❣

  • @WryTrvr
    @WryTrvr Před rokem

    That was like beautiful 3 dimensional water physics sometimes

  • @konradburnett688
    @konradburnett688 Před rokem

    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.

  • @yodayoda4137
    @yodayoda4137 Před 3 lety +1

    That looks like a water simulation in the end

  • @guilhermealveslopes
    @guilhermealveslopes Před 3 lety

    Quite awesome!

  • @jomy10-games
    @jomy10-games Před 3 lety

    That’s impressive!

  • @kalebbruwer
    @kalebbruwer Před 3 lety +2

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

  • @kedman1095
    @kedman1095 Před 3 lety +3

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

  • @bennysh
    @bennysh Před 3 lety +1

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

  • @gimmethedata4256
    @gimmethedata4256 Před 3 lety +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.

  • @BossBeneBaby
    @BossBeneBaby Před 3 lety

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

  • @cleanlens
    @cleanlens Před 3 lety +1

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

    • @cleanlens
      @cleanlens Před 3 lety +1

      @CZcams Algorithm oh poop

  • @sourcelocation
    @sourcelocation Před 3 lety

    Awesome video! How do you compile the project?

  • @thegamingdeath123
    @thegamingdeath123 Před 2 lety +1

    it looks nice

  • @yudhistira7231
    @yudhistira7231 Před 3 lety

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

  • @MarcCastellsBallesta
    @MarcCastellsBallesta Před 3 lety

    I love it!

  • @cantstopthis1123
    @cantstopthis1123 Před 3 lety +1

    this is gonna blow up

  • @angrywolfjr7164
    @angrywolfjr7164 Před 3 lety

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

  • @felulaval4742
    @felulaval4742 Před 3 lety

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

  • @Kian00
    @Kian00 Před 3 lety

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

  • @Jake629
    @Jake629 Před 3 lety

    pretty colours

  • @RedStinger_0
    @RedStinger_0 Před rokem

    end result is great album cover material

  • @turlupouet
    @turlupouet Před rokem

    Love it

  • @dnsbrules_01
    @dnsbrules_01 Před 3 lety +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.

  • @jasyak2
    @jasyak2 Před 3 lety +1

    Short answer: 180K
    Long answer: This video

  • @susitu6609
    @susitu6609 Před 2 lety

    1 engine was harmed in the making of this video

  • @exel001
    @exel001 Před 3 lety +17

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

    • @PezzzasWork
      @PezzzasWork  Před 3 lety +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 Před 3 lety +5

      @@PezzzasWork nice bug

  • @akrickok3482
    @akrickok3482 Před 3 lety

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

  • @blackdragoncool
    @blackdragoncool Před 3 lety +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  Před 3 lety

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

    • @blackdragoncool
      @blackdragoncool Před 3 lety

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

  • @AhmedHan
    @AhmedHan Před 3 lety +1

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

  • @anothrnoml
    @anothrnoml Před 3 lety +4

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

  • @auroralshine6176
    @auroralshine6176 Před 3 lety

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

  • @Tiniuc
    @Tiniuc Před 3 lety +3

    I want to play around with this so much right now

  • @Alexander_Sannikov
    @Alexander_Sannikov Před 3 lety

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

  • @ariawatson_
    @ariawatson_ Před 3 lety

    Everybody gangsta till the wall starts peeing

  • @ruskyivanich2107
    @ruskyivanich2107 Před 3 lety

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

  • @donovanmahan2901
    @donovanmahan2901 Před 3 lety

    Wow the resulting structure actually has a temperature

  • @gabef9538
    @gabef9538 Před 3 lety

    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.

  • @UserName-ik9qm
    @UserName-ik9qm Před 3 lety

    i like the sound

  • @BirdTho
    @BirdTho Před 3 lety

    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.

  • @markoftheland3115
    @markoftheland3115 Před 3 lety +7

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

    • @PezzzasWork
      @PezzzasWork  Před 3 lety +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 Před 3 lety

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

  • @IdkwhymynamecantjustbeCody

    This is how rock layers are formed.

  • @Sciencedoneright
    @Sciencedoneright Před 3 lety

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

  • @agvulpine
    @agvulpine Před 3 lety

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

  • @typicalhog
    @typicalhog Před 3 lety

    Insane!

  • @entized5671
    @entized5671 Před 3 lety

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

  • @unluckypanda5448
    @unluckypanda5448 Před 3 lety

    the thumbnail made me think it's powder toy

  • @eco1969
    @eco1969 Před rokem

    Great example of sedimentary deposits over time

  • @bluethumbbuttoneek9465

    Now that's alotta balls

  • @Lol-pz9ow
    @Lol-pz9ow Před 3 lety

    Bit rate does BRRRRR

  • @doomer6951
    @doomer6951 Před 3 lety

    Hey, thats pretty good! Does it have any optimization? What cpu does it run on?

    • @paavorotsten508
      @paavorotsten508 Před 3 lety +3

      fuck you and your username making middle-click scrolling impossible

    • @logicbuilder1204
      @logicbuilder1204 Před 3 lety

      @@paavorotsten508 i am able to do it fine, what happens when you do it

    • @paavorotsten508
      @paavorotsten508 Před 3 lety

      @@logicbuilder1204 goes sideways

    • @logicbuilder1204
      @logicbuilder1204 Před 3 lety

      @@paavorotsten508 try control zero

    • @kaninchengaming-inactive-6529
      @kaninchengaming-inactive-6529 Před 3 lety +2

      @@logicbuilder1204 Didn't help so I tried zooming out instead, and now I'm finally able to scroll down again

  • @priuxls
    @priuxls Před 3 lety +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 Před 3 lety

      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 Před 3 lety

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

  • @gdgames9585
    @gdgames9585 Před 3 lety

    Owo new skittles ad?

  • @TheSuckerOfTheWorld
    @TheSuckerOfTheWorld Před 3 lety +14

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

    • @thatotherandrew_
      @thatotherandrew_ Před 3 lety +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 Před 3 lety +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 Před 3 lety

      It's vsync

    • @lm1338
      @lm1338 Před 3 lety +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.

  • @starshipsn1013
    @starshipsn1013 Před 3 lety

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

  • @vwr0527
    @vwr0527 Před 3 lety

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

  • @abhay_more
    @abhay_more Před 3 lety

    The final looks like Perlin noise

  • @miranda.cooper
    @miranda.cooper Před 3 lety

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

  • @atlasua2021
    @atlasua2021 Před 3 lety +1

    Multithreading or GPU?
    Very cool! I also want to write my own physics engine, only using a shader.
    -
    Очень круто! Я также хочу написать свой собственный физический движок, только используя шейдер.

  • @Lb.q2
    @Lb.q2 Před 3 lety +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 CZcams view count but how large is actually is

  • @Pinupopinion
    @Pinupopinion Před 3 lety

    Ok now add a function where she loves me back

  • @arkhaic1792
    @arkhaic1792 Před 3 lety +1

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

  • @HugoStuff
    @HugoStuff Před 3 lety +1

    Money you make per second in idle games be like:

  • @Mark00747
    @Mark00747 Před 3 lety

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

  • @thecoolguy1233
    @thecoolguy1233 Před 3 lety

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

  • @AHSEN.
    @AHSEN. Před 3 lety

    cooool

  • @Luke-mf6tg
    @Luke-mf6tg Před 3 lety

    Could you put people on that land you created?

  • @MichaeltLoL
    @MichaeltLoL Před 3 lety +3

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

    • @PezzzasWork
      @PezzzasWork  Před 3 lety +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 Před 3 lety

      @@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  Před 3 lety +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!

  • @Wolfoxy1904
    @Wolfoxy1904 Před 2 lety

    my pc would die at the second ball

  • @Ur_N0.1_fan
    @Ur_N0.1_fan Před 3 lety

    Hewwo mister ObamA? HEWWOOoo?!

  • @mr2octavio
    @mr2octavio Před 3 lety

    I would like to know what errors are in the engine

  • @cakedon
    @cakedon Před 3 lety

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

  • @Aresydatch
    @Aresydatch Před 3 lety

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

  • @xKreesherZ
    @xKreesherZ Před 3 lety

    this just went from few balls bouncing to fluid simulation

  • @virdvird
    @virdvird Před 3 lety

    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

  • @Henrix1998
    @Henrix1998 Před 3 lety

    How on earth the physics time just stops growing?

  • @AlexTrusk91
    @AlexTrusk91 Před 3 lety +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

  • @zashbot
    @zashbot Před 3 lety

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