Oh, wow This is exactly what I needed, in the exact coding language I needed it. It just popped in my recommended, magic! Thank you so much for the video :)
Thanks, glad I could help out. Also if you want to take the "from scratch" to another level I recommend to watch the handmade hero live stream recordings
Great, exactly what I needed! One note: maybe don't include timelapse? It is useless because you can't really read any code that fast and it flickers too much. Better would be just to show important code fragments or paper fragments or something.
Super cool! The only feedback I have is that whoever wrote 12:13 should take a variable naming course :))) "elastic" is the only descriptive word they use and ff course no math can exist without some nameless "g" and "h" for extra confusion
Haha, maybe g and h really aren't that great. But to be fair I don't know what I would call them either, because they just describe the functions in equations (8) and (9). Also the picture you are seeing is just a compilation of all the equations, meaning I cut out the explanations. Additionally, the fact that this is a paper might prevent them from choosing longer variable names because of formatting requirements. Lastly, thank you!
Hi again! I'm trying to implement this from scratch just like you, but I am curious why you have a CosAngle member variable for SoftBodyEdge (15:34 on the right). Is it for future videos to add different types of constraints? Also... what is LambdaLength and LambdaAngle?
Hi, all of the angle variables were meant for future use (bending constraints). When I planned this I thought I could store the cosine of the angle instead of the angle itself to save some operations, but as it turns out this doesn't work. So this was a planning mistake which I corrected later. The lambda variables are the ones of their respective constraint, so LambdaLength for the distance constraint and LambdaAngle for the bending constraint (again the last one future use). The reason I defined these in the struct instead of in the simulation algorithm is because I like to minimize the amount of temporary memory allocations to improve efficiency (not having to alloc and free all the time) and to reduce the number of failure points while running the game.
You should know basic of tensor calculation, Tensor Calculus, Continuum Medium Mechanic, Analysis Finit deformation , elasticity-plasticity, C+++, Geometry Differential, …, SFML for me and GLSL , easy to make complex soft body (generalized boundary) . But starting is so hard. I worked on in 2001 with OpenGL at that time.
Yeah it‘s so much stuff. Luckily this is just for a game, so visual plausibility and computational cost have a higher priority than physical accuracy in terms of choosing the right simulation model. And so far the mass spring model seems to work
Hey! Great video really inspiring! I'm actually trying to develop my own jiggle solver inside SideFX Houdini as a challenge, helps a lot your explanation on the papers love it!
Is the physics-added code also available? I am also wondering how this method is related or not to that old C++ library no game used as far as I know except demoscene where cows were falling from above and there were spikes that either deform or even cut them! It was an awsome lib and I remember my friend at uni tried to replicate it in 2D with similar contraints + mass technique!!! I mean we knew the 3D one used that and it sounded really similar to thiis. That source code surely predates 2006 though with some years so someone else might have already found this out earlier....
Lmao that sounds crazy. Do you have a link to a video or the library or something? I haven't open sourced the physics added code, no. Maybe I will once the game is finished, not sure. But if you are interested in the code, I would recommend the Ten Minute Physics channel, where Matthias Müller himself goes over small demos that he open sourced. Be prepared though, the code is in javascript
@@blackedoutk Found it! By that I mean I thought about it hard enough to remember its name... "Realmatter tech by Alec Rivers". There is video about that in youtube, but the stuff is earlier than the upload of that video to YT! But when my friend at university (the one I used to go to acm icpc competitions with and now he works at google actually so is and always was really smart guy) just by seeing the vids wrote it from scratch in 2D. You could break textured boxes into pieces with his demo that I have no idea if he still has. Basically he made the same dots + springs approach, just because we were mor about the "make it possible to destruct and deform it and stay it such" that is what was his focus too - just like Alec's code. There were some tech docs from this demo and how to do it randomly around the net at the time... Also look up "realmatter zombies" for an other YT vid of the same.
@@u9vata Cool! But also pretty brutal. And the Thomas the Tank Engine one was funny lol. They even published a paper about their method "FastLSM: Fast Lattice Shape Matching for Robust Real-Time Deformation". I haven't read all of it but it seems they use the shape matching method described in the paper "Meshless Deformations Based on Shape Matching" from 2005 and improved its efficiency by reusing intermediate results. Contrary to the mass spring implementation I used, their shape matching method defines small regions of points that are then matched (accelerated towards) the same region in the original model (with adjusted rotation and translation). Figure 3 from the 2005 paper I mentioned depicts this pretty well. Because this matching is quite limited in terms of deformation capabilities, they use multiple overlapping regions of a grid generated from the original surface mesh. Definitely interesting. Glad you remembered it
there is a channel "Ten minute physics", the man is physics researcher from Nvidia does tutorials and deep explanations of computer physics. He is also the man behind behind paper with deformation simulations in realtime, and that paper also got implemented in PhysX and UE 5.1
But its still great to see you implementing physics and facing practical problems with practical solutions, because he was more into theory behind implementations
Hey amazing video, it inspired me to try make something similar for a university project, but after looking at soft body examples in HTML/js from ten minute physics I'm lost on how to implement the constraints in C++/openGL. Could you please share some of the basic code for setting up the scene itself with the cube? It would be very helpful
Thank you, that's great to hear. I'm building a basic 3d renderer like in this video in my livestreams currently and the code is on my GitHub as well. You may want to look at that, the only problem is that it's not done yet 😅 But for the missing parts and constraints you can join my discord server, where we can discuss this. The link is in the comments of my second (currently latest) livestream recording
Hi! Can I ask you why the equation at 14:04 looks different from the equation on the Ten Miute Physics video about XPBD? th-cam.com/video/jrociOAYqxA/w-d-xo.html
Hi, there are a few reasons why they look different. First, the algorithms in the Ten Minute Physics video only does a single solver iteration. This means that any λ in the Δλj equation here can be ignored, since before the solver runs, each λ is initialized to zero. As to why, this is explained in section "Iterations vs. Sub-steps" and specifically at 7:05 he mentions that λ is not needed anymore. The consequence is that the part "- alpha j tilde λij" of equation 18 can be ignored. Secondly, because we are only dealing with point masses, the inverse mass matrix is still a (block) diagonal matrix. So the term "∇Cj M^-1 ∇Cj^T" is really just the dot product between ∇Cj with itself, where each summand is weighted by the corresponding mass. The absolute value lines | | are used because each of his ∇Ci are still vectors. Also, note that the index j in my video does not correspond to the indices of C in the denominator of his video, because he lists these equations for a single constraint, whereas here the equations take the whole system of constaints into account for which ∇C is actually a matrix (the jacobian matrix). So the λ in his video equals the Δλj here and ∇C1 and ∇C2 in his video are entries in the vector ∇Cj, meaning ∇Cj1 and ∇Cj2. Next, the alpha tilde j is not present in his denominator because he set it to zero, meaning the springs are infinitely stiff. Equation 18 is a really general way to describe the algorithm. You wouldn't implement it this way if your constraint was really simple, like a linear spring. So if you simplify equation 18 with all the knowledge of what you have at about linear spring constaints, set alpha tilde to zero and ignore λ (not Δλj), you end up with the definition of λ in the Ten Minute Physics video. For linear springs the gradient vectors of the constraints of the relevant point masses are of length one, so their dot product or squared length is 1. Lastly for Δx it's very much the same reasons. In constrast to Δλj however, Δx is a vector that contains the delta positions of all point masses. So even more general that the Δλj equation. If you were to multiply everything out and only look at a single constraint Cj and a single point mass x1, you would end up with the equations in his video. I hope this helps, it's a bit difficult conveying this through text. If you didn't understand some part of it don't hesitate to ask
Hi! Great video : ) What version of MacOS are you using / are you on an M series Mac? I've had issues with the opengl drivers in the past where I can't use any textures because of a driver related shader compilation error for sampler2Ds. I was on an M1 mac air using opengl 4.1. Thanks! Have you seen this shader compilation error: UNSUPPORTED (log once): POSSIBLE ISSUE: unit 0 GLD_TEXTURE_INDEX_2D is unloadable and bound to sampler type (Float) - using zero texture because texture unloadable
Hi, thanks :) I haven't seen this error yet, my machine is an M2 MacBook Air currently on 13.5. How are you binding your textures? It seems to be an issue with that.
@@blackedoutk Hi, its me again. So the funny thing is that it must have been either 1) Fixed in a recent MacOS update or 2) It was a problem with using GLFW as a windowing library. In any case, I've implemented it as a fork to your cg-papers repo and it works : ) Thanks!
Yeah, implementing physics is quite math heavy. But I think math can be fun too if someone explains it well and doesn‘t just write down a bunch of formulas. I would really like to implement fracture eventually but currently I don‘t know how it‘s done. Have to do some more reading
It definitely seems to be easier to implement than other methods, but I still don't know enough about these other methods to really give you good advice. Honestly you can create a fun fps game without actual physics, so I think using XPBD can get you very far and I would use it
Storing the masses in a diagonal matrix seems like a bit of a waste. I can see how it makes the maths notation simpler, but is the best way to do it in a computer?
That would indeed be a waste, not only memory wise, but also computationally because you would multiply with zero all the time. Generally when you need to implement operations with a sparse matrix you can store only the non zero elements and use a special multiply algorithm. In the case of a diagonal matrix it's even simpler, you just store the diagonal in an array and scale each vector component accordingly when multiplying. In the algorithm here it's not even necessary to perform the full matrix multiplication because for the delta lambda and delta x all except two of the constraint gradients are zero, which means the masses for these gradients can be ignored in the sum.
There are some tutorials on the Ten Minute Physics TH-cam channel that I would recommend. For now I want to focus on my devlog series. But if you have specific questions you are welcome to ask me.
It would definitely be less error prone, but sometimes I like implementing things myself to also get a better understanding of the math. The only downsides of using glm I can think of right now are that huge template libaries are often hard to read and add a significant amount of compile time. Also, I would have to use their code style preferences, like camel case.
I used an M2 MacBook Air for this connected to an external monitor. macOS has this build in program that lets you take screenshots or screen recordings. it's really nice and the quality is really good imo. The only thing I thought was a bit annoying it doesn't let you set the temporary save file location (at least last time I checked), so it will always first write to your SSD and then copy to where you set the save path, which was an external drive in my case
And one more thing.Do you use opengl on mac?I was in doubt does emulated opengl have any effect.Thinking will I have any tradeoff or unnecessary issue faced on any arm64 machine
@@shivanshuraj7175 Yes I use OpenGL on MacOS, I don't think it is emulated though, just not really updated to newer APi versions. So I'm stuck at OpenGL 4.1. I can't remember having faced any unnecessary issues just because of OpenGL on Mac
That's kind of what it felt like for me following a tutorial a few years ago. In reality it was much less of course but still 1k lines or something. Enormous amounts of setup. 1k lines for a software renderer is more understandable I would say
@@homeopathicfossil-fuels4789 Yeah, Vulkan and other apis offer much more control over the gpu and its interaction with the cpu. Synchronization for example is one thing that scared me away. I would say they are even tougher than OpenGL. But part of why the first triangle in Vulkan is so long is also because you have to fill in setup structs like do you want to draw filled or wireframe and so on, whereas in OpenGL you just use the preset values.
@@blackedoutk That makes my mouth water! Been looking for a new low level mindscrew to fiddle with for a while. I normally work in pure C (on PC) or assembly (on experimental homebrew systems or their emulations) and sometimes when I am feeling "wasteful" or "lazy" I take it up a notch of abstraction to C++. Sweet! Thanks for your information!
Oh :/ I study computer science, so I attended a few math and simulation lectures. What about you? I try to explain these concept using mostly high school knowledge, but maybe I don't always succeed in that. Is there something specific I could explain further or link resources to that might help you?
@@blackedoutk Well, every school is different and I'm from russia actually, I suppose the teaching programs are very much different. I am currently in college, I love programming and staff. aaand I'm bad at physics. It would help to know more about physics and how it's done via code, do you have any cool videos about that?
@@desine_ Yeah, probably. Is college like university in some sense? For physics and code I would recommend the TenMinutePhysics TH-cam channel. He creates tutorials and also uploads the code to his GitHub, though it might be a bit technical. For physics in general there are probably a lot of resources but I remember watching some Khan Academy videos and recently I watched the friction video by Professor Dave Explains. He has a playlist about physics as well: th-cam.com/play/PLybg94GvOJ9HjfcQeJcNzLUFxa4m3i7FW.html I haven't watched all of it but they look like good introductory videos. If you watch them, let me know if they were helpful.
@@blackedoutk Thank you, I will start with the playlist. "Is college like university in some sense?" - College prepares you to a job, at least it should, but does not go deep into math or physics. I think university is more focused on "how and why", college on the other hand only introduces you to some topics.
This video is great. Any chances for video explaining this part - th-cam.com/video/MgmXJnR62uA/w-d-xo.html . Looks like firs equation is: ma = grad( Potential Energy) ? Then discreet version, then something about this potential energy 'wrapped' in constraint C matrix (equation?). Not sure what is - alpha. Will try what chat gpt will say... but still, video woud be great.
Thanks. I wanted to make a video where I explain the derivation of these equations, but that would still be far in the future, I've been quite busy lately unfortunately. You're right, the first two equations are mass times acceleration being equal to the gradient of the potential energy and then discretized. For the definition of the potential energy I would encourage you to write down the potential energy of a Hookean spring and then for multiple ones. The potential energy of multiple springs will just be the sum of the potential energies of the individual potential energies, but if you choose fitting vectors and matrices, you can rewrite the sum as matrix multiplications. Which is what equation 5 is. The inverse of alpha for example contains the spring constants of all the springs as a diagonal matrix. Again, writing this down for small examples and seeing what is what really helps here, I am sure you can figure this out. You might also wanna look at the paper where I got this from "XPBD: Position-Based Simulation of Compliant Constrained Dynamics", which contains some further although admittedly very brief explanations. The only thing I am still not exactly certain about is why they introduce the lambda formulation. I looked at the referenced paper by Servin et al but it's still not really clear to me. Also because you mentioned chat gpt, I would be careful with it for maths, sometimes it creates resonably looking proofs for example but upon further inspection there are small errors which make the proof invalid. At least that's my experience, so I would be careful with that thing
I enjoy your editing style and appreciate that you have decent audio balancing.
I'm happy you like it. Would you believe me if I told you that I recorded this with a built-in microphone?
This is amazing! I love the editing and commentary style. This should have way more views.
Woah thanks! I am happy you think that
nice explanation! Thank you, I am looking forward to your next video.
Very high quality content. Thanks for sharing. Thanks
Happy to hear that, thank you
Really nice video and a great addition to Matthias Müllers Videos about this topic
Thanks! Glad you think so
Oh, wow
This is exactly what I needed, in the exact coding language I needed it.
It just popped in my recommended, magic!
Thank you so much for the video :)
Haha cool! Thank you for your nice comment
this is fantastic. I wanted to write my own game from scratch for a while but never knew where to start. Thank you
Thanks, glad I could help out. Also if you want to take the "from scratch" to another level I recommend to watch the handmade hero live stream recordings
Really cool :D Always wanted to see some more implementations of this!
Thanks :D
physics from scratch? wow amazing!! Irresistible Recommendations
Haha great to hear
Phenomenal video! The commentary, editing, and visuals are on point!
Great to hear thanks! Now I am curious though what you think of my newer episodes if you have watched any
Great, exactly what I needed! One note: maybe don't include timelapse? It is useless because you can't really read any code that fast and it flickers too much. Better would be just to show important code fragments or paper fragments or something.
I thought about that too, will keep that in mind for the next video. Thanks for your feedback
Super cool! The only feedback I have is that whoever wrote 12:13 should take a variable naming course :)))
"elastic" is the only descriptive word they use and ff course no math can exist without some nameless "g" and "h" for extra confusion
Haha, maybe g and h really aren't that great. But to be fair I don't know what I would call them either, because they just describe the functions in equations (8) and (9). Also the picture you are seeing is just a compilation of all the equations, meaning I cut out the explanations. Additionally, the fact that this is a paper might prevent them from choosing longer variable names because of formatting requirements. Lastly, thank you!
Hey that maths explanation was actually quite nice and made it really easy to understand :) Good video!
Thank you :)
This man is on steroids 💪🏽 ... Crazy man 🔥🔥🔥!
I have learned a lot from that ! thanks
Hi again! I'm trying to implement this from scratch just like you, but I am curious why you have a CosAngle member variable for SoftBodyEdge (15:34 on the right). Is it for future videos to add different types of constraints?
Also... what is LambdaLength and LambdaAngle?
Hi, all of the angle variables were meant for future use (bending constraints). When I planned this I thought I could store the cosine of the angle instead of the angle itself to save some operations, but as it turns out this doesn't work. So this was a planning mistake which I corrected later.
The lambda variables are the ones of their respective constraint, so LambdaLength for the distance constraint and LambdaAngle for the bending constraint (again the last one future use). The reason I defined these in the struct instead of in the simulation algorithm is because I like to minimize the amount of temporary memory allocations to improve efficiency (not having to alloc and free all the time) and to reduce the number of failure points while running the game.
Physics and 3D rendering; "Welcome back my friends to the show that never ends...", ELP.
Haha, that seems to fit quite well
@@blackedoutk Started my journey over 40 years ago, and still trudging along. Good work, hope to see more. Cheers from GED.
@@garydeschaines Thank you! 40 years is impressive. It’s such an exciting field. Cheers
You should know basic of tensor calculation, Tensor Calculus, Continuum Medium Mechanic, Analysis Finit deformation , elasticity-plasticity, C+++, Geometry Differential, …, SFML for me and GLSL , easy to make complex soft body (generalized boundary) . But starting is so hard. I worked on in 2001 with OpenGL at that time.
Yeah it‘s so much stuff. Luckily this is just for a game, so visual plausibility and computational cost have a higher priority than physical accuracy in terms of choosing the right simulation model. And so far the mass spring model seems to work
Very cool, continue !
Thank you
I refuse to believe this guy only has 1k subs
I was actually quite happy when I saw 1k this morning haha. But even happier you think I should have more
Hey! Great video really inspiring!
I'm actually trying to develop my own jiggle solver inside SideFX Houdini as a challenge, helps a lot your explanation on the papers love it!
Thank you :) it's nice to hear that
Very cool dude! 😊
Thank you :))
Great stuff. I am trying to do some physics as well. But lost quickly in those formulas
Thanks :) Yeah it‘s quite a bit of formulas
This is really helpful! Thx!!!
Happy to hear that
Great video, thanks a lot! Grüzi :)
Is the physics-added code also available?
I am also wondering how this method is related or not to that old C++ library no game used as far as I know except demoscene where cows were falling from above and there were spikes that either deform or even cut them! It was an awsome lib and I remember my friend at uni tried to replicate it in 2D with similar contraints + mass technique!!! I mean we knew the 3D one used that and it sounded really similar to thiis. That source code surely predates 2006 though with some years so someone else might have already found this out earlier....
Lmao that sounds crazy. Do you have a link to a video or the library or something?
I haven't open sourced the physics added code, no. Maybe I will once the game is finished, not sure. But if you are interested in the code, I would recommend the Ten Minute Physics channel, where Matthias Müller himself goes over small demos that he open sourced. Be prepared though, the code is in javascript
@@blackedoutk Found it! By that I mean I thought about it hard enough to remember its name... "Realmatter tech by Alec Rivers". There is video about that in youtube, but the stuff is earlier than the upload of that video to YT! But when my friend at university (the one I used to go to acm icpc competitions with and now he works at google actually so is and always was really smart guy) just by seeing the vids wrote it from scratch in 2D. You could break textured boxes into pieces with his demo that I have no idea if he still has. Basically he made the same dots + springs approach, just because we were mor about the "make it possible to destruct and deform it and stay it such" that is what was his focus too - just like Alec's code.
There were some tech docs from this demo and how to do it randomly around the net at the time...
Also look up "realmatter zombies" for an other YT vid of the same.
@@u9vata Cool! But also pretty brutal. And the Thomas the Tank Engine one was funny lol. They even published a paper about their method "FastLSM: Fast Lattice Shape Matching for Robust Real-Time Deformation". I haven't read all of it but it seems they use the shape matching method described in the paper "Meshless Deformations Based on Shape Matching" from 2005 and improved its efficiency by reusing intermediate results.
Contrary to the mass spring implementation I used, their shape matching method defines small regions of points that are then matched (accelerated towards) the same region in the original model (with adjusted rotation and translation). Figure 3 from the 2005 paper I mentioned depicts this pretty well. Because this matching is quite limited in terms of deformation capabilities, they use multiple overlapping regions of a grid generated from the original surface mesh.
Definitely interesting. Glad you remembered it
thanks for the video
😃
"masterpiece"
I'll take this as a compliment, so thanks:D
there is a channel "Ten minute physics", the man is physics researcher from Nvidia does tutorials and deep explanations of computer physics. He is also the man behind behind paper with deformation simulations in realtime, and that paper also got implemented in PhysX and UE 5.1
But its still great to see you implementing physics and facing practical problems with practical solutions, because he was more into theory behind implementations
Yeah, he does some pretty awesome things. I even used some of the techniques he presents in his tutorials for my game. Glad you like my videos as well
Hey amazing video, it inspired me to try make something similar for a university project, but after looking at soft body examples in HTML/js from ten minute physics I'm lost on how to implement the constraints in C++/openGL. Could you please share some of the basic code for setting up the scene itself with the cube? It would be very helpful
Thank you, that's great to hear. I'm building a basic 3d renderer like in this video in my livestreams currently and the code is on my GitHub as well. You may want to look at that, the only problem is that it's not done yet 😅 But for the missing parts and constraints you can join my discord server, where we can discuss this. The link is in the comments of my second (currently latest) livestream recording
Cool :)
:D
Hi! Can I ask you why the equation at 14:04 looks different from the equation on the Ten Miute Physics video about XPBD? th-cam.com/video/jrociOAYqxA/w-d-xo.html
Hi, there are a few reasons why they look different. First, the algorithms in the Ten Minute Physics video only does a single solver iteration. This means that any λ in the Δλj equation here can be ignored, since before the solver runs, each λ is initialized to zero. As to why, this is explained in section "Iterations vs. Sub-steps" and specifically at 7:05 he mentions that λ is not needed anymore. The consequence is that the part "- alpha j tilde λij" of equation 18 can be ignored.
Secondly, because we are only dealing with point masses, the inverse mass matrix is still a (block) diagonal matrix. So the term "∇Cj M^-1 ∇Cj^T" is really just the dot product between ∇Cj with itself, where each summand is weighted by the corresponding mass. The absolute value lines | | are used because each of his ∇Ci are still vectors.
Also, note that the index j in my video does not correspond to the indices of C in the denominator of his video, because he lists these equations for a single constraint, whereas here the equations take the whole system of constaints into account for which ∇C is actually a matrix (the jacobian matrix). So the λ in his video equals the Δλj here and ∇C1 and ∇C2 in his video are entries in the vector ∇Cj, meaning ∇Cj1 and ∇Cj2.
Next, the alpha tilde j is not present in his denominator because he set it to zero, meaning the springs are infinitely stiff.
Equation 18 is a really general way to describe the algorithm. You wouldn't implement it this way if your constraint was really simple, like a linear spring. So if you simplify equation 18 with all the knowledge of what you have at about linear spring constaints, set alpha tilde to zero and ignore λ (not Δλj), you end up with the definition of λ in the Ten Minute Physics video. For linear springs the gradient vectors of the constraints of the relevant point masses are of length one, so their dot product or squared length is 1.
Lastly for Δx it's very much the same reasons. In constrast to Δλj however, Δx is a vector that contains the delta positions of all point masses. So even more general that the Δλj equation. If you were to multiply everything out and only look at a single constraint Cj and a single point mass x1, you would end up with the equations in his video.
I hope this helps, it's a bit difficult conveying this through text. If you didn't understand some part of it don't hesitate to ask
@@blackedoutk Was not expecting this detailed explanation! Thank you so much :)
Hi! Great video : ) What version of MacOS are you using / are you on an M series Mac? I've had issues with the opengl drivers in the past where I can't use any textures because of a driver related shader compilation error for sampler2Ds. I was on an M1 mac air using opengl 4.1. Thanks!
Have you seen this shader compilation error:
UNSUPPORTED (log once): POSSIBLE ISSUE: unit 0 GLD_TEXTURE_INDEX_2D is unloadable and bound to sampler type (Float) - using zero texture because texture unloadable
Hi, thanks :) I haven't seen this error yet, my machine is an M2 MacBook Air currently on 13.5. How are you binding your textures? It seems to be an issue with that.
@@blackedoutk Hi, its me again. So the funny thing is that it must have been either 1) Fixed in a recent MacOS update or 2) It was a problem with using GLFW as a windowing library. In any case, I've implemented it as a fork to your cg-papers repo and it works : ) Thanks!
@@benceweisz1063 Oh, that's strange. But great that it works now
Learn a bit but great to see how it work. It a lot math XD. I wonder how fracture works later on destruction.
Yeah, implementing physics is quite math heavy. But I think math can be fun too if someone explains it well and doesn‘t just write down a bunch of formulas.
I would really like to implement fracture eventually but currently I don‘t know how it‘s done. Have to do some more reading
For a first-person shooter game, would XPBD be the best choice for physics simulation?
It definitely seems to be easier to implement than other methods, but I still don't know enough about these other methods to really give you good advice. Honestly you can create a fun fps game without actual physics, so I think using XPBD can get you very far and I would use it
Very cool! 😃 And, will this project be open source?
Thank you 😄 Maybe at some point, I'm not sure yet
Storing the masses in a diagonal matrix seems like a bit of a waste. I can see how it makes the maths notation simpler, but is the best way to do it in a computer?
That would indeed be a waste, not only memory wise, but also computationally because you would multiply with zero all the time. Generally when you need to implement operations with a sparse matrix you can store only the non zero elements and use a special multiply algorithm. In the case of a diagonal matrix it's even simpler, you just store the diagonal in an array and scale each vector component accordingly when multiplying. In the algorithm here it's not even necessary to perform the full matrix multiplication because for the delta lambda and delta x all except two of the constraint gradients are zero, which means the masses for these gradients can be ignored in the sum.
I want to do this myself too. Can you drop a full tutorial without time lapse?
There are some tutorials on the Ten Minute Physics TH-cam channel that I would recommend. For now I want to focus on my devlog series. But if you have specific questions you are welcome to ask me.
why not use glm for the matrix math?
It would definitely be less error prone, but sometimes I like implementing things myself to also get a better understanding of the math.
The only downsides of using glm I can think of right now are that huge template libaries are often hard to read and add a significant amount of compile time. Also, I would have to use their code style preferences, like camel case.
Do you develope on pc or laptop?how you record and develope the sametime?
I used an M2 MacBook Air for this connected to an external monitor. macOS has this build in program that lets you take screenshots or screen recordings. it's really nice and the quality is really good imo. The only thing I thought was a bit annoying it doesn't let you set the temporary save file location (at least last time I checked), so it will always first write to your SSD and then copy to where you set the save path, which was an external drive in my case
And one more thing.Do you use opengl on mac?I was in doubt does emulated opengl have any effect.Thinking will I have any tradeoff or unnecessary issue faced on any arm64 machine
@@shivanshuraj7175 Yes I use OpenGL on MacOS, I don't think it is emulated though, just not really updated to newer APi versions. So I'm stuck at OpenGL 4.1. I can't remember having faced any unnecessary issues just because of OpenGL on Mac
First triangle in Vulkan... 1.3 GIGABYTES? I wrote my first software renderer in less than 1k lines of C a few years ago, what even happened?
That's kind of what it felt like for me following a tutorial a few years ago. In reality it was much less of course but still 1k lines or something. Enormous amounts of setup. 1k lines for a software renderer is more understandable I would say
@@blackedoutk Damn, and I thought OpenGL was tough. Something something vulkan has lower level access, right? That would explain the experience :p
@@homeopathicfossil-fuels4789 Yeah, Vulkan and other apis offer much more control over the gpu and its interaction with the cpu. Synchronization for example is one thing that scared me away. I would say they are even tougher than OpenGL. But part of why the first triangle in Vulkan is so long is also because you have to fill in setup structs like do you want to draw filled or wireframe and so on, whereas in OpenGL you just use the preset values.
@@blackedoutk That makes my mouth water! Been looking for a new low level mindscrew to fiddle with for a while. I normally work in pure C (on PC) or assembly (on experimental homebrew systems or their emulations) and sometimes when I am feeling "wasteful" or "lazy" I take it up a notch of abstraction to C++. Sweet! Thanks for your information!
@@homeopathicfossil-fuels4789 Haha cool, yeah that might suit your needs
JIGGLE
exactly
Ah, C++ build system... I can recommend premake5
Don't scare me 😭
Now do that for c64
😵💫
what background knowledge do you have?
it looks very not understandable from my perspective :/
Oh :/ I study computer science, so I attended a few math and simulation lectures. What about you?
I try to explain these concept using mostly high school knowledge, but maybe I don't always succeed in that. Is there something specific I could explain further or link resources to that might help you?
@@blackedoutk Well, every school is different and I'm from russia actually, I suppose the teaching programs are very much different.
I am currently in college, I love programming and staff. aaand I'm bad at physics.
It would help to know more about physics and how it's done via code, do you have any cool videos about that?
@@desine_ Yeah, probably. Is college like university in some sense?
For physics and code I would recommend the TenMinutePhysics TH-cam channel. He creates tutorials and also uploads the code to his GitHub, though it might be a bit technical.
For physics in general there are probably a lot of resources but I remember watching some Khan Academy videos and recently I watched the friction video by Professor Dave Explains. He has a playlist about physics as well:
th-cam.com/play/PLybg94GvOJ9HjfcQeJcNzLUFxa4m3i7FW.html
I haven't watched all of it but they look like good introductory videos. If you watch them, let me know if they were helpful.
@@blackedoutk Thank you, I will start with the playlist.
"Is college like university in some sense?" - College prepares you to a job, at least it should, but does not go deep into math or physics. I think university is more focused on "how and why", college on the other hand only introduces you to some topics.
@@desine_ Ah, okay. University is a lot of theory indeed
OMG a 1 Giga Bytes hello triangle file hahahaha
This video is great. Any chances for video explaining this part - th-cam.com/video/MgmXJnR62uA/w-d-xo.html . Looks like firs equation is: ma = grad( Potential Energy) ? Then discreet version, then something about this potential energy 'wrapped' in constraint C matrix (equation?). Not sure what is - alpha. Will try what chat gpt will say... but still, video woud be great.
Thanks. I wanted to make a video where I explain the derivation of these equations, but that would still be far in the future, I've been quite busy lately unfortunately. You're right, the first two equations are mass times acceleration being equal to the gradient of the potential energy and then discretized.
For the definition of the potential energy I would encourage you to write down the potential energy of a Hookean spring and then for multiple ones. The potential energy of multiple springs will just be the sum of the potential energies of the individual potential energies, but if you choose fitting vectors and matrices, you can rewrite the sum as matrix multiplications. Which is what equation 5 is. The inverse of alpha for example contains the spring constants of all the springs as a diagonal matrix.
Again, writing this down for small examples and seeing what is what really helps here, I am sure you can figure this out. You might also wanna look at the paper where I got this from "XPBD: Position-Based Simulation of Compliant Constrained Dynamics", which contains some further although admittedly very brief explanations. The only thing I am still not exactly certain about is why they introduce the lambda formulation. I looked at the referenced paper by Servin et al but it's still not really clear to me.
Also because you mentioned chat gpt, I would be careful with it for maths, sometimes it creates resonably looking proofs for example but upon further inspection there are small errors which make the proof invalid. At least that's my experience, so I would be careful with that thing
Hessel Summit
what does this mean
hi, i'm going to ask you once. when you do something, will you please do it, and not do it from scratch. scratch ain't doing you no favors holmes.
Is that a quote or something?