No sleeping here, there is a huge lack of technical content on youtube at this level, these videos are killer. Keep it up. Would love to see the deep-dive on your fluid sims for your engine project.
I don't think you actually realize how much effort goes into creating a video like this. "At this level" there's extremely little content on the entire youtube.
@@Alexander_Sannikov I'm not sure exactly how to interpret this, but I never said it was easy. Also, that is not strictly true since there is an immense amount of highly technical content on youtube, just not in the realm of individuals writing interesting things from scratch, and not laid out to present novel experiments, Sebastian Lague-style.
@@theDemong0d what I mean is that 99% of sebastian league style content requires much less knowledge and effort than a video like this. UPD nvm, I think I read your original post wrong. I think I read "huge lack" as "huge block", or something like that.
This is incredible. Constraint solving is stuff you do early on in an engineering degree but I never cared for it because I was always into the more computational stuff. Seeing you come at this from the computational side first has given me a whole new perspective.
You're my new favorite RU-vid content creator. WOW! This level of knowledge and expertise is something I rarely see on RU-vid. KEEP UP THE GOOD WORK!!!
Interesting to see someone reviving the (at least my) experience of writing a physics engine. It was really a brain crushing journey for me to do this in the 90' with less accuracy, much less computing power, my very immature knowledge of math, let alone internet resources on this topic. But I have strong memories indeed from my eureka moment after real-time simulating a cloth, and a few weeks later seeing the same idea rendered on a Silicon Graphics cluster on a computer fair in Brussels.
@@AngeTheGreat the algorithm will bless your latest engine sound simulator video, it is the most impressive work i have ever seen. Great things and huge potential in your work!
C++ Developer are so cool. I don't think any Physics teacher of my shool could ever imagine, something like this can be done with, what they teach at school.
You could do the video capture with a pretty simple GStreamer pipeline. GStreamer can directly take your video buffers and automatically wire up a pipeline to encode into pretty much any arbitrary format. I would also say that, since you're using C++, you could group "x", "y", and "theta" into a 'struct' and create operators for different arithmetic operations for that 'struct'. This would make the code shorter and clearer--and make mistakes less likely if you can rely on well-written operators to do some of the repetitive steps for you.
I've used GStreamer before though I don't think it would have been any simpler than simply using ffmpeg directly, it was a fairly straightforward thing to implement. Ordinarily I would done this and have done it on my other projects (ie using classes and overloaded operators). I wanted to keep this codebase minimalistic and almost C-like. I like to try different coding styles on different projects. I found that it didn't really cause issues on this project and I found it readable, though I'd probably just do it with classes for vectors in the future.
"i wrote this advanced physics simulator" "oh and then i ran into some problems with making the video" "thus i quickly built my own screen capturing software which works better than this giant open source program that's been around since 2012" okay
All your stuff is incredible. You’re going to have a million subs in the next 2 years if you keep it up. My advice is to not abandon your long form content in favor of shorts. Your issue earlier with the car rendering video was that you didn’t have critical mass of viewership. Now that your channel is blowing up, a long term project requiring a lot of work will likely be rewarded even more.
Awesome stuff! Highly recommend you look into iterative techniques (Gauss-Seidel, or more complex Conjugate Gradient). They are probably in fact easier to implement than the Gaussian Elimination, and you can terminate iterative approaches when the error is low enough. Convergence rates are almost always related to conditioning of the system being solved, which will depend on what combination of constraints you have in your simulation. Note that isn't worse than the elimination case: poor conditioning also causes numerical instability in that algorithm as well.
Excellent suggestion, you definitely know your stuff! I actually did implement Gauss-Seidel but I didn't mention it in the video because I didn't want to confuse people haha... But you're right that iterative approaches are great. Next step will be to implement Conjugate Gradient since that'll be faster and also slightly more robust (for redundant constraints, etc.). Thanks for watching and thanks for the suggestion!
Hey @brandon, what do you think of LevenBerg-Marquadt (probably mis-spelled!). I have read several papers recently where they use that for solving systems (not physics) as it is supposed to be very fast and more 'optimisable', removing zeros etc. Wondering if you thought it would be good for a physics engine?
I've studied physics for 2 years and computer science for another 3 years. I'm already thought of doing something like that, but it's very impressive to see how well you've done it. There are so many layers of complexity to what you're showing
As I'm currently preparing for an upcoming exam in numerical analysis, I find it interesting to see this really cool application of most of the methods I've learned! I'd like to write my own physics-engine right now, if I didn't have to study at the moment 😅
A note on implementation: your RK solver is very tightly coupled with the design of the system you're integrating. Usually it's best to try to decouple the integrator from the system itself and implement it more generically. For ordinary ODE's you just need a function that calculates a vector of derivatives from a vector of coordinates, and that's all your integrator needs. And your physics engine can _index_ into those arrays to access coordinates of any given rigid body.
Just discovered your channel, and i see a lot of advanced, neat projects that really sparks my interest. This physics engine is very cool ! Im impressed to see that you make all that in C++, it genuinely makes me want to make similar stuff on a low level. That's really inspiring (even the nerdy mathematical details ! Along with the sources in the descriptions, those are the crunchy bit for me). Keeps up the awesome work !
Welcome to the channel! I try to work on projects that really challenge me and I'm glad that you enjoy my content. Hopefully my channel continues to help/inspire you in your software journey. Thanks for watching!
Plz release a good Physics game for iPad lmao. I’ll pay 8 buck. I wanna design my friends missing finger in a real time easy to use physics engine. Please do.
Some constraints (such as rolling constraint, universal joint, etc) can be represented both as an extra body with simpler constraint attached to the bodies that you want to connect to start with, or with a more involved jacobian and no extra body. I recommend initially not wasting time implementing complex jacobians for joints that are not experiencing heavy load and implement them using just an extra body. If/when they become a problem, you can replace the extra body with a page of code for its jacobian, but they must converge to the same exact result in the limit of the extra body having zero mass.
Oh I see, might look into that. I think I might have gotten carried away with the rolling constraint, I really wanted to make it work for some reason lol
You can try GeoGebra. I do not know any codding and math. But I can make many thinks with using only shapes, dots and points. It is hard to say about some most complex formulas (what created by expert professors or other scientists.) can ultra easy to find as different way without numbers. And some of them works better in many ways. For example I was tried smiler things like you did. I think you can try to use spiral to make that object fall. Spiral shapes, turns, and size can be change for velocity, mass and high. I think spiral should reflect to other side if object fall down point is upper than object connection pivot point. I can not explain this by cods or formulas but I wish it will work better.
All this goes far over my head but it's so impressive to see someone make things like this and to share it online, even creating a screenrecorder in the meantime. Crazy!
Lol I dont understand a single fuckin thing you said here. I don't know how people become programmers, this shit is like Mandarin to me only I'd have better luck learning that. I can't speak robot.
That's an amazing project! I loved the video, even though I couldn't understand the mathematical stuff, it was still entertaining. Great job with your content, I think you should get more attention with how good your videos are made!
Thank you! Don't worry about not understanding the math immediately, I didn't either. It's one of those things where I had to really sit down and study it seriously before I understood. It's also why I didn't talk about it much in the video 😂
really cool engine! the sims with the rolling constraint look awesome, so the tedious math was totally worth it 😅 physics aside, i really loved the visuals. great job!
I knew as soon as I started this project that rolling constraints were gonna be a thing, no matter how painful it was haha... Thanks for watching and glad you enjoyed it!
Since you've implemented a general constraint system, would it be possible to directly constrain the system energy to what it "should" be, a la Lagrangian Mechanics?
The color scheme of the video is something you could work on. Dark themes can be hard to read but mixing different themes makes it worse. Worst offender is the PDF document which had a light color sceme (for some reason??)
I can understand the PDF being out of place (which also annoyed me but I couldn't really justify spending any more time trying to fix it) but I thought everything else used pretty consistent colors?
You got a new subscriber. I arrived to your channel by a reddit post with a link to your engine simulation video, and I guess now I'm binge watching all your videos. Amazing work man.
I started to learn Vim at one work experience (who used also Linux like I did privately) and managed to finally code only with Vim. Then I got mocked on my second work experience where they hate everything except the only one thing they use (Windows and just shortcuts in IDEs) and said that I know nothing and Linux is not for Professionals (It's the first time I saw such a dirty code in a company). It felt great to watch this video and seeing that Vim is used.
It's actually not that hard, I just used the same encoder used in OBS and did some basic thread synchronization to get it to work in real-time. Thanks for watching!
@@AngeTheGreat just the fact that you've given yourself all the prerequisite knowledge necessary to to look at up, and understand exactly how to implement it in your own project is still flooring me. you've like minmaxed for useful coding skills and creative problem solving. incredible stuff, great job, looking forward to your next upload!
Oh god that first animation you showed triggered my rigid body dynamics ptsd No but this video is actual gold. Thank you for making this. I’m so glad I found it. Also, thank you for including some of the math.
It's almost midnight I'm tired and I'm watching someone build a Physics Engine but then he drops the word "Jacobian" and my mind shoots awake for a few minutes.
@@AngeTheGreat honestly, consistency isn't something i care about. take it at your own time and i'll enjoy whatever you put out, whenever you put it out.
how did you actually render an image on the screen? graphics libraries like openGL are pretty confusing to me, the only experience i have is making shaders in glsl
Watching such things makes me wanna learn programming but also makes me realize I am too dumb for such stuff. It's a skill I'd like to posses and code whatever I want, but I always failed when tried to learn programming. First time I tried I was around 14, then around 15, then around 19 (I had to cause of college). From time to time I did really simple projects, but always when I wanted to do something more complicated it was just too hard for me. I am too dumb for this shit. I felt like you had to have a really big knowledge in order to do some simple tasks. Really big effort for small results. It kinda annoyed me. Could I ask you what you do for a living? Programming game engines and doing/knowing all the numerical methods and so on are your hobby and you learn this by yourself, or it is related to your work? I am always amazed that some people are so smart and at once I am kinda sad that I am too stupid and lazy to do such things as well. Like brah, you use Jacobians in the code. I had this in my college and other stuff like that and I often wondered what the heck are such things. Later on, I came across a lot of things by myself and realised they are useful (e.g. derivatives). But Jacobians!?
What you don't see in my videos is the many years of failure and frustration that came before them. Even to this day, I don't find a lot of what I do easy and I know I have a lot to learn. I tried and failed throughout my teenage years to make interesting games or just any useful software in general and until recently most of my projects got little to no attention from anyone. I worked as a professional programmer for a few years but I've recently moved to working on video game development and RU-vid full-time. All of what you see on my channel was learned in my free time and was not at all related to my day-job. My suggestion to you is: don't give up and start as small as you can. Create some simple and complete programs before moving on to anything too challenging and overwhelming. Once you find something that you enjoy doing and start working at a pace that works for you, you'll find that it's much easier to motivate yourself and expand upon the project. Good luck to you and thanks for watching!
@@AngeTheGreat Yeah, I can imagine you went through a lot of work and frustration. I saw a video with time stamp called "This animation taked definitely too long" (or something like this) and I was like "holy shit, did he do this animation in his own 3D renderer?" When I watch such stuff I realise there is a lot of "behind the scenes" work and sometimes cannot even imagine how much had to be done. And that amazes me. That's why I am mainly fascinated - that you don't ever give up and just learn more, more and you keep going. Thanks for the tip. One of my problems is that at some point I get either too frustrated or too bored. I tend to switch my 'hobbies'. I do what is interesting for me at one point. I cannot really stick to one thing. In the result I know a little bit of everything but nothing besides that. But then I come across a person like you and you know maths, programming, Blender, game dev, video edition. That's amazing. I can do only basic stuff in all of these. But I bet you spent a lot of time learning all of this. I recently tried to learn Blender and barely spent 2-4 hours a week. Maybe that's my problem - I am too lazy to get to work. When I actally open Blender or code editor and have some idea I can get drawn in for long hours. But most of the days I prefer to do lazy stuff or read about chimpanzees or something interesting for me in a given moment. Besides laziness there is the frustration. I remember trying to code a JPG to ASCII converter. Sounded simple - just load an image, get pixels values, calculate grayscale value and put out characters in a notebook. But simple things such as loading image was actually hard. I had to use some libraries to do it easily (I thought it can be done without it as I felt it's kind of 'cheating'). I very often realised that some stuff is much harder than I thought or I didn't understand the code at all. It happens same for me in Blender. I get frustrated when something doesn't work or works different than I want. Not understanding things frustrate me. Ended up writing kinda messy comment, but TL;DR: I am sometimes too lazy/too bored/interested in too many random things at once/too frustrated to make my learning efficient. And that's why I am amazed that you just keep going but you also can do several things at such good level. Thank you for the tips and also good luck with the channel, you're doing great job.
You can try using a symplectic integrator such as velocity verlet to increase numerical stability so that the energy/system does not diverge over time.
Are there any books on coding nature / physics simulations that you’d recommend? I know the Nature of Code book, but it’s a bit too simple, I am looking for something more advanced.
Dude, elaborate on the math part! It is nice to see the theory I've learned in University applied to create a physics engine! A video on the math explanation would be awesome
Endless enigmatic book in all languages. You can write a book with mirrors in all languages of the world. You can speak two languages at once, you just need to find the perfect reflection, same content, different translation. Infinite Mirrors. Pi 3.14 XBooks. Hybrid language!!!!!!!##!!!!!!!!!!
Hi Ange, good to see this informative content, at 7:30 you are try solving the Lagrangian multipliers using Baumgarte Stabilization technique, can you suggest me any other method/material for solving the Differential Algebraic Equations?
Trying to apply a rolling constraint by using the equation s = r * theta, where s measures the distances rolled by the roller. The derivative of this equation in the jacobian matrix blows up due to a zero in the denominator ... :(
Great work! Just a small nit, here... There are many ways to discretise the vector system: dx/dt = f(x,t) 1 - LHS: -------------- First, we can discretise the lefthand-side using the base definition of the derivative: dx/dt = (x(t+dt) - x(t) )/dt This one-side difference is the part they call "Euler". It's first order accurate, with errors being proportional to dt^2. 2 - RHS: -------------- Where in time you choose to evaluate the RHS is also important. The Forward-Euler method evaluates the RHS at t=t, thus: (x(t+dt) - x(t))/dt = f(x,t)
FYI you showed explicit Euler integration which is very unstable. Look up symplectic Euler, which is a one line of code change which will make your simulation both more accurate in terms of conserved quantities and vastly more stable at large time steps
10:30 Is friction included in the interaction between the circle and the plane it's sitting on? Like how does circle rotation change direction? How does angular velocity of the circle affect the energy of the system?
Have you been investigating into adaptive time step simulation? I'm trying to implement a continuous time model that would conserve impulses and energy of a system, but update forces only when needed to keep integration errors within a chosen tolerance. I would be grateful for any advice or material on that.
In the best way you’re content reminds me of those calming sessions in college studying on khan academy. Some things go over my head but your approach is so cool to watch, your content is criminally slept on!’