The fact that multi-threading made it not deterministic was really interesting
@TheRainHarvester
Жыл бұрын
Only because threads can vary in their timing of when they run because they can be used by the OS. But if you write the code correctly, it will be deterministic because the objects won't vary according to which got updated first.
@ateslabattery115
Жыл бұрын
@@TheRainHarvester but from the outside, you never know which will be used until you check... sounds familiar
@rorymax
Жыл бұрын
Technically still deterministic though :p
@pascha4527
Жыл бұрын
@@rorymax yeah but an entire os could be considered chaotic. Some process depend of the internet. The system is so complex it will never be deterministic unless unplugged from the internet and the code is running without an OS. Still an interesting topic tho, I want to dig deeper.
@rorymax
Жыл бұрын
@@pascha4527 oh it’ll still be deterministic, there would just be so many variables that you’d never be able to replicate or even know all the starting conditions. But if you had all those variables, and enough time and computation power, you’d be able to determine the outcome
@steviousmusic
Жыл бұрын
I'll never regret subscribing. Edit: POG almost 1K likes
@dhiahassen9414
Жыл бұрын
🤣🤣🤣🤣
@attepatte8485
Жыл бұрын
Same
@Luke-me9qe
Жыл бұрын
Me neither
@rodakdev
Жыл бұрын
Facts!
@SquarePancakes
Жыл бұрын
Nobody will
@MrSprinkles
Жыл бұрын
Your original verlet integration video is what got me more interested in C++ & physics simulation, so excited to see this new one come out!
@PezzzasWork
Жыл бұрын
I hope you will like it :)
@firexgodx980
Жыл бұрын
I would try out rust if I were you. It's like C++, but has a first party build system and package manager. It's also memory safe without a garbage collector!
@tyrendel
Жыл бұрын
@@firexgodx980 +1 and SFML is being (ported to Rust) -> wrapped in rust 🙂
@firexgodx980
Жыл бұрын
@@tyrendel awesome, where can I follow the progress?
@sofomryu
Жыл бұрын
how about mojo? grammar and library of python and speed of C++
@dakeyras4146
Жыл бұрын
Thanks for the new video! I've not done much related to programming, but collision optimization has been an interest of mine for quite a while. It's great to see such an easy explanation into spacial partitioning.
@Rodzorex
Жыл бұрын
Great work as always. You're one of the few channels that actually excites me when a new upload appears in my feed.
@PezzzasWork
Жыл бұрын
Thank you!
@bookshop7337
Жыл бұрын
Back when I was growing up, Black and White 2 by Lionsgate was my jam. In the screen before the main menu, a bunch of particles streamed into a box and made the Lionsgate logo.... but you could also mess around with them using your mouse and screw the whole thing up. But if you didn't, it always ended up perfectly. I used to wonder how on earth they managed to implement a physics engine that kept producing the same result over and over, and now almost a decade later you've answered that lingering question. Keep up the amazing work!
@Gregzenegair
8 ай бұрын
Do not use floats and only integers, and you'll be fine.
@chrisrichfield8906
7 ай бұрын
Lionhead. Lionsgate is the film production company.
@official-obama
Ай бұрын
@@Gregzenegairintegers also have rounding errors, floats are also deterministic, floats also do not spontaneously change
@S-K.
Жыл бұрын
I love seeing the grains appear in the crystal lattices that appear. I'd love to see this applied with more physics rules to simulate microstructures to create visual aids for understanding alloys, solid state chemistry, etc.
@zagmongor
3 ай бұрын
Totally agree, I flipped when I saw the grain boundaries forming with minimal physics incorporated
@eamonburns9597
Жыл бұрын
That has got to be the coolest "thanks for watching" screen I have ever seen
@NaviaryMusic
Жыл бұрын
Watching the objects construct the image is so satisfying!! I'm sure if you made videos dedicated to showcasing more images being filled, and even made shorts, they would be very successful!
@glumpfi
Жыл бұрын
This is so satisfying :) It would be interestig to see how the chicken picture changed if you re-run the simulation with the exact same settings, except slightly changing the settings of one single object. Like i depiction of the butterfly effect. The more complex the interaction is, the more warping of the chicken should be visible.
@leonhardolaye-felix8811
Жыл бұрын
That would’ve been awesome
@Pauly421
10 ай бұрын
@@leonhardolaye-felix8811 Thank you for using the apostrophe correctly :D
@eboatwright_
Жыл бұрын
Wow. Your videos are so technically impressive! Great job
@acreatorqads
Жыл бұрын
I LOVE YOUR VIDEOS!!! Your code is so elegant in so many ways, and your videography is perfect, plus your voice, just everything man, seriously awesome!
@GabeRundlett
Жыл бұрын
Amazing video as always!! I love how you show a simple version of the code as a demonstration tool. Very similar to Sebastian Lague, I really hope I could get this good at video making at some point.
@asherkime5910
Жыл бұрын
Sebastian Lague is the greatest teacher I've ever had
@RayznGames
Жыл бұрын
Such a joyful video dude. (I scrambled myself around 2 months ago to optimise an application with thousands of collidable objects , couldn't get the multithreading tho) Awesome job!
@sierpinskibrot
Жыл бұрын
This is one of your best videos so far man I can tell you spent a lot of time on this and it payed off well
@thefunbunns
Жыл бұрын
You always outdo youself on the outro, love your work and knowledge! Thanks for sharing it with all of us!
@nandakoryaaa
Жыл бұрын
This is mind blowing. I always thought fluid/particle simulation is something very complicated, but here it is effortless. Thanks for the sources! I'll try to make my own engine using platform-independent compiler and graphic library.
@maticz3923
Жыл бұрын
I've been having problems trying to multithread my sim, that idea to use 2 passes is genius! Thank you so much
@professionalnerd1095
Жыл бұрын
Your physics simulation videos are absolutely mesmerizing... and so educational! I've been following along implementing my own physics engine!
@TheBarretNL
9 ай бұрын
I keep coming back to these video's because they are such good learning subjects, thanks for making them Pezza! you are an absolute legend.
@nightwolf6233
Жыл бұрын
I absolutely love how well you demonstrated the issues of multithreading in a very visual manner by showing how multiple threads could not produce the same deterministic result if overlaps between threads are not properly handled. I really feel like I learned some valuable things from this video. Thanks, it was awesome!
@mogyoros
11 ай бұрын
I know the acronym STEAM is a bit of a reach (STEM + Arts), but this work is truly at the intersection of science and art. Well done - and beautifully explained!
@spowrei
4 ай бұрын
your videos are really inspiring. whenever i watch your videos i find myself while codding
@weeblewonder
7 ай бұрын
The visualisations in this video are amazing. They communicate the problem space so effectively. Nice work!
@sollybunn
Жыл бұрын
This led me on my own rabbit hole for vertlet physics, and each step you did took me hours to do. Your videos are amazing!
@puppergump4117
Жыл бұрын
The chicken is now a symbol of success
@dragonfire4356
Жыл бұрын
your videos always make my day. and every time they blow my mind
@IamUAV
11 ай бұрын
This is so fascinating. I'm going to school so that I can work on stuff like this and it makes me so excited when I see videos like this. Thanks for all the insight.
@rim7961
Жыл бұрын
man, this is depressing and impressive at the same time. I've spent a whole year in last year of my BSc making a 2d physics engine and its still was wonky af to a point that its an embarrassment to show anyone, and here you whoop it up in like 2 months that is effectively a perfection
@abrahamdomingo8239
Жыл бұрын
tbf, it's not like he made the physics engine from scratch, he just found a great way to calculate collisions in a very efficient way
@kartonrad
Жыл бұрын
You also have to concede that thr yter only uses 2d circles, whose collisions are veryy easy to check and require much less work! Dont beat yourself up about it
@maxfofax5471
Жыл бұрын
You're going to learn a lot by trying, failing, then either figuring it out or seeing how someone else did it. The older you get, you don't stop failing when you try something new or difficult, you just know how much time to give yourself to figure it out. I get why it's depressing and impressive, but I hope that you're still excited to solve these interesting problems just so you can feel your own brain grow, you'll get there before you realize!
@Creaform003
Жыл бұрын
Each improvement increases the probability of the next improvement. You didn't spend a year making a 2d physics engine. You spent a year improving the quality of all future physics engines you will go on to build.
@stevea.b.9282
11 ай бұрын
also he can only do this in two minutes because he spent years working on improving his skills and understanding. Keep going and you'll be amazed at how much progress you make.
@basmeuwissen8644
Жыл бұрын
I would be really interested to see the addition of other shapes to the simulation. Adding polygons or even non convex shapes would be a lot more challenging but very interesting.
@Arkensor
Жыл бұрын
Very well made video. Love the animations during the explaination at the beginning
@daonlyowner6631
Жыл бұрын
The ideas are so easy, but I never would have even thought about them. So good!
@rentierriche2873
Жыл бұрын
La meilleure chaîne qui me vend du rêve, encore un super programme comme d'habitude 🙂
@khatharrmalkavian3306
Жыл бұрын
Here's an interesting problem I ran into some months ago. I'd like to propose it to you and see if you come up with something cool, if you're interested. Imagine a 2D plane populated by entities with circular colliders, not dissimilar to what you're doing here. There is also an attractor entity which moves around arbitrarily. Each simulation step, the entities find the direction of the attractor as a normalized vector and store it as an intended direction of motion. They then check for collision with one another, and when overlaps are found, they add the response vector to their stored vector, so that they end up with a sum of all their desired motion vectors. This vector is then normalized and multiplied by the desired speed of the entity, so that they will move toward the attractor while repelling one another if they get too close. So far so good. The issue arose when I started using SIMD to accelerate the simulation and allow for more active entities. The SIMD radically improved the rate at which they can all find the direction toward the attractor, but for collision I ran into the problem that the data for the SIMD was not sorted into regions in order to accomplish the grid optimization like you did here. It's possible to sort them by their x positions, but it seemed like rearranging them this way for every update would take up more time than the SIMD calculation would save. Unfortunately, I set that project down because of some life issues and now I don't know if I still have it around, but I'd be interested to hear if you have any ideas about to deal with this kind of problem. Thank you for the great videos!
@andreyrumming6842
Жыл бұрын
A fascinatingly complex issue. So effectively the whole problem is unsorted data every frame?
@khatharrmalkavian3306
Жыл бұрын
@@andreyrumming6842 Mainly, yes. The SIMD registers hold four 32-bit values, so I would select an entity to test and load it into a register twice (x,y,x,y) and then have a pointer to the other entities that would be used to load the other registers, then increment by 4 and continue loading, etc. By interleaving the loads and the math it was possible to get good performance from this, because one register could be working while the next is loading, and each register is doing the math for two entities at a time. This required the position vectors to be serialized, so each entity had an index into an array of x,y pairs. This meant that sorting the pairs would also require updating the indices in the owning entities, which was another layer of complexity. I'm certain that big game companies with fancy physics engines have some way that they're able to cheaply sort entities so they don't have to do On^2 collision tests every frame. I just don't know what that method is. Alternatively, they may all just be doing this kind of thing in CUDA or something.
@Bari_Khan_CEng_CMarEng
9 ай бұрын
I love this, the start of a computer game engine! The background music is great, adds audible depth to learning about the computing techniques
@lievenpetersen
Жыл бұрын
I've recently been struggling with this exact problem, this has given me some new ideas, thanks!
@devindykstra
Жыл бұрын
This is an awesome video! It seems to me if you wanted to simulate objects with an arbitrary radius you would need each cell to be the size of the largest object. I'm not sure if there's a better way to do it, but maybe that's a good idea for a follow up video?
@user-sl6gn1ss8p
Жыл бұрын
you could make the object register into multiple cells and also read a larger neighborhood. That being said, as far as I know there are other space partitioning techniques which don't use a fixed grid and are more adaptable
@MrDelusive
Жыл бұрын
Quad Tree for 2D and OctTree for 3D is pretty much that
@eigentensor
Жыл бұрын
Great video, it was already clear from your previous ones but you underscored it well here :) Also I think you should switch the order of y and x loops at 5:00 for better memory access in canonical order
@comeinhendy8931
Жыл бұрын
I don't know how 2d Arrays are implemented in the language he's working with, but it makes sense. It should help with the cache.
@PezzzasWork
Жыл бұрын
I am not using 2D arrays (which are indeed row major). I use column major because it allows for better load balancing between threads since in the simulations of the video objects are horizontally spread
@dandymcgee
Жыл бұрын
Loved the multi-threading aspect. Fun stuff!
@PrimeGym01
Жыл бұрын
C'est tellement impréssionant! Continue avec les vidéos incroyable mon gars.
@lisyarus
Жыл бұрын
A great tutorial! I usually just do a dt step followed by N collision steps, gotta try your substepping method sometime :) I've once made a similar tutorial, without threading but with friction, damped springs, and ball-stick collisions.
@PezzzasWork
Жыл бұрын
The big advantages with sub steps is that, since objects travel smaller distances in one physics frame, errors are a lot easier to handle for the solver and it also greatly mitigate the tunneling effect, leading to way more stable simulations
@funnyduck4568
Жыл бұрын
@@PezzzasWork what is the tunneling effect?
@CelestialityRW
Жыл бұрын
i would pay money for a thing that lets you generate an image with thousands of circles, honestly the coolest coding thing i've seen in a while!
@jaafartheking153
Жыл бұрын
Your channel is too good to be real. That was fascinating. Keep the clean work.
@n4rzul
Жыл бұрын
Wow. That was amazing. Best video about coding I've ever seen! Subbed on the spot!
@skippytheelder
Жыл бұрын
Are you interested in chemestry? Because I would love to see your interpretation of an atomic-level physics simulator.
@tetryds
Жыл бұрын
This is pretty cool but it is just a standard collision simulation
@debuggers_process
Жыл бұрын
@@tetryds I've done some chemistry simulation in Lennard-Jones potential, it's pretty fun to play with, trying out different combinations of interaction parameters. I have several videos on this topic on my channel.
@Kycilak
Жыл бұрын
@@tetryds Molecular simulations are not exactly difficult though. There is much to do in implementation but the principles are not much more difficult than this.
@Krazylegz42
Жыл бұрын
Awesome as always! I'm curious if the grid-iterating approach causes any kind of bias in the physics? Like if updating the collisions left-to-right in the grid adds any kind of preference for stuff moving to the right?
@official-obama
Ай бұрын
every collision moves the objects in opposite directions, so the center of mass doesn't change
@DanWills
Жыл бұрын
Wow! So cool! I have loved the idea of known-future-simulation-states for 'formation' effects (I work in vfx) and this really did that in a superb way, top work Pezzza!
@thelastdankbender4353
Жыл бұрын
I like how your video quality is increasing with every video. Awesome stuff
@lennarth.6214
Жыл бұрын
Very nice! Have you tried k-d-trees yet? If you have, what performance gains were there
@GrumpDog
Жыл бұрын
I'm curious about that too.. For something like this, I'm not sure how much further benefit could be obtained by using k-d trees. Tho I'm by no means an expert on them, in this case I wouldn't think the empty space would cost much different, and the objects are all the same size, so not much dynamic adjustment is needed in that regard. The one time I tried implementing them, it cost more in performance to manage the kd-tree, than it took to just run everything in a fixed-grid like this video used. Tho again, I probably wasn't using them as expertly as other people might.. heh
@PezzzasWork
Жыл бұрын
Never tried them but I tend to think that very simple / straightforward and cache efficient structures generally win, specially if the world size isn’t huge
@user-dh8oi2mk4f
Жыл бұрын
@@GrumpDog What algorithm did you use for adjustments/refitting?
@GrumpDog
Жыл бұрын
@@user-dh8oi2mk4f I don't remember, it was years ago and I was barely comprehending tutorials on it at the time, as it was. I just remember the feeling like it was the programming equivalent of chasing after a perpetual motion machine, or teetering on the edge of "The Tyranny of the Rocket Equation".. lol
@manjitsingh-jj5wi
Жыл бұрын
Dude I am a high schooler and i wanted to make a thread pool for multithreaded collision detection and i even thought there would be issue with 2 threads writing to the same Ram adress and i would have fixed it in the same way.i am feeling proud that I thought of all the same optimisation as you.i first thought of a qaud tree but couldn't find a way to multithread it
@EpicVideoGamer7771
Жыл бұрын
This is so cool! You are such an inspiration to me, as someone who is learning raylib for C++
@stevea.b.9282
11 ай бұрын
that's a very cool effect, and thanks for explaining so clearly.
@SLPCaires
Жыл бұрын
woooo!
@brickisao2999
9 ай бұрын
Now write a physics system ON scratch
@Flook1
Ай бұрын
How are you most popular comment what the hell
@gamingfizz1803
Ай бұрын
@@Flook1it’s only 3 likes lol
@gamingfizz1803
Ай бұрын
Id love for him to do that.
@djentinga3267
Жыл бұрын
Extremely satisfying, awesome work!
@abigweed1811
Жыл бұрын
Insanely enjoyable and well made video! This is all stuff I've seen in Game Dev school, ah the nostalgia
@dragonminz602
Жыл бұрын
Realy intresting video! Thanks for showing the code and your progress
@shallowdive
Жыл бұрын
That's awesome! The overall structure looks like a polycrystal and those imperfections - like dislocations. The hexagonal planar structures look exactly like graphene.
@Skeffles
10 ай бұрын
Fantastic video and great explanation behind everything!
@JackAllpikeMusic
Жыл бұрын
I'd absolutely love to see more of this. This is fantastic.
@PezzzasWork
Жыл бұрын
Thank you very much!
@JackAllpikeMusic
Жыл бұрын
@@PezzzasWork you're an inspiration :)
@harshans7712
Жыл бұрын
This was really awesome, I really loved the video and was really interesting and Informative, thank you!
@realbrickbread
Жыл бұрын
This is so cool! The last simulation really resembled saturn with its rings :)
@aleksandarstankovic4476
Жыл бұрын
Very useful! Deffinetly helped, like all of your videos!
@Loerad
Жыл бұрын
Watching you write code is so satisfying.
@raptordad6653
5 ай бұрын
This is fascinating! Thank you for sharing ❤👍
@mySDK3333
Жыл бұрын
I like how your "Thanks for watching" being always pretty long, it feels like really sincere.
@Kazner0h
8 ай бұрын
Very cool demonstration. I'm subscribed.
@busy_beaver
Жыл бұрын
Fantastic! Really beautiful simulation! I have also invented the same technique by myself (I know that I'm not the first who though about it but at least I figured it out by myself), but never got to realize it. Glad to see how well it actually works! Probably it will run a couple dozen times faster if you run it with CUDA.
@sudo4582
7 ай бұрын
I thought you'd use OpenMP to manage threads, but you actually programmed the communication, thanks for sharing such amazing piece of work!
@ChipboardDev
Жыл бұрын
bro your content is insane and very inspiring, keep it up
@PezzzasWork
Жыл бұрын
Thank you very much!
@xingzhexin8843
Жыл бұрын
It's been a long time since the last time I paused a video and go down to intentionally click sub+like before I finish a video because I don't want to forget about it. More content this quality sir and you're on top of KZitem.
@MKVideoful
Жыл бұрын
Awesome. You really improved the audio good work.
@mitchstilborn
Жыл бұрын
Dude that outtro image was just pure swag. Well played
@Dominik-K
Жыл бұрын
Very interesting video, I've actually been thinking about implementing my own basic physics checker for a really tiny multiplayer game to increase the efficiency and lower the server requirements (though I'm using C#11, but the algorithmical / threading issues apply all the same) thanks a bunch for this very interesting video
@SpringySpring04
Жыл бұрын
Hey Pezzza! I really love watching your videos, they're really entertaining! The style of video you make is very underrated and very helpful to people like me who have a little bit of experience in programming. After watching this video I was inspired to make something physics-based and was wanting to make something like a simulation of atoms, with protons, neutrons, electrons, and a couple of other subatomic particles, but got a little lost on how to handle the forces and interactions between them (not to mention it's been a few months since I last did a physics simulation, so I'm a bit rusty). I was wondering if you could perhaps create something like this in a future project?
@simaocharpentier2046
Жыл бұрын
Incredible work! I'm not into programming, yet you managed to make it really interesting, even for me. Worth a lil' subscription imo. Also, your accent sounds like you're french. Edit: just checked and yep you are
@MS-sx1oo
7 ай бұрын
Very nice that you also provided a link to the source code. tyvm
@VHenrik007
Жыл бұрын
Great video, easy to understand. Good job!
@NotAFoe
Жыл бұрын
Love these so much. Thx for doin them pezzza :)
@gustavosalmeron2013
Жыл бұрын
That was art. Congratulations, gentleman.
@YoghurtKiss
Жыл бұрын
Wow, this is a super nice physics engine, and it's so simple that even I understand the code.
@PanicAtTehCisco
Жыл бұрын
I liked seeing the grain boundaries between the particle "crystals"
@ciCCapROSTi
Жыл бұрын
This video gave me the push the ditch a physics engine for my project and write my own. They are way too smart for my needs, and a simpler one like this (with some additions that fit my needs, like grouping objects or base displacement on weight) will provide a much better base for the logic.
@LukeAps
Жыл бұрын
Yes. Spatial partitioning and multithreading, the keys to good performance.
@JoshuaHoltz
Жыл бұрын
The worst part of yoir channel is that it's so high quality that we don't get frequent videos. Keep it up! Love the content.
@DRUYD
Жыл бұрын
as always, great video and explanation
@WindowChicago
Жыл бұрын
God bless you, author! Thank you very much!
@culpritdesign
Жыл бұрын
Very enjoyable. Thank you for this content.
@gustavoadolfomelindres
Жыл бұрын
If this isn't quality content, I don't what is. Thanks for another perfect video.
@dusan.1967
Жыл бұрын
Thanks for teaching me such a cool trick
@xXstealseekerXx
9 ай бұрын
This has to be one of the best outros for a video i have seen
@cocccix
Жыл бұрын
The deterministic thing makes it amazing
@robot7338
Жыл бұрын
incredible video! thanks for sharing!
@Zytron
Жыл бұрын
That outro was S-Tier, loved it.
@vialomur__vialomur5682
Жыл бұрын
Wow thanks fo this type of videos like it so much!
@tiotio3666
Жыл бұрын
Checking for a collision between grid cells can be done only for half of the neighbouring cells. For example you can only check left, top-left, top and top-right neighbours. All other collisions for examle between current cell and right neighbour, will be checked once that neighbour becomes current cell
@PezzzasWork
Жыл бұрын
Yes absolutely, I still do the full check since it is like doing 2 solver iterations but faster that really doing 2 iterations and it help a lot with stability
@baltakatei
10 ай бұрын
The partitioning of the grid into thread groups (“causal domains”) effectively creates a “speed of causality” for your cosmos which is like the speed of light for our cosmos.
@ItsIdaho
Жыл бұрын
That sunglass chicken image is so simple yet it blows my mind. Love this
@Neceros
Жыл бұрын
This looks amazing.
@chubbybunny6272
Жыл бұрын
Kind of unrelated but I like how your simulation also can show lattice structures and lattice imperfections. Pretty cool.
Пікірлер: 978