|
Hello all! I've been wanting to create another TL KnowHow article to go over a topic of interest: creating a custom physics engine. My last one talked a lot about high level summaries without too much implementation details. The physics engine one was going to be all about the implementation details.
However TL KnowHow pretty much shut down, so I don't really have the option anymore. Instead I put them up on my website and they will just chill out there forever.
So is anyone here interested in reading up a bit on what it is like to code your own custom physics engine? It happens to be a lot of geometry and linear algebra, and a lot of interesting details. I started up an article series that will be going over all the details involved in creating a small custom 2D physics engine. Here's the list of what I've finished so far:
Just wanted to share the articles I'm creating here in case anyone was going to miss them, since TL KnowHow is a goner. I'll of course be adding more articles to the series as time passes. Since everyone loves pictures I'll share a few from the posts.
Change of basis from left to right.
Stacked oriented boxes from my own physics engine.
And lastly here's a sweet equation I wrote in code comments! + Show Spoiler [code] +Eq 14: Impulse = -(1 + Restitution) * (VelocityRelativeAtoB dot n) ------------------------------------------------- 1 1 (rA cross n)^2 (rB cross n)^2 ----- + ----- + -------------- + -------------- MassA MassB InertiaTensorA InertiaTensorB
|
United States24483 Posts
Something to keep in mind about coding physics engines (and other things like that): it's more effective to have a science specialist learn coding in order to apply expertise to a program than it is to try to teach the scientific expertise to someone who purely knows how to code.
For a simple 2d engine this may not be the case, but it is true in the 'working world' for the most part.
Thank you for sharing this... sounds interesting.
edit: you might want to suggest how people can learn the physics necessary to come up with their own engines! We can't all have degrees in physics :p
|
On March 28 2013 11:11 micronesia wrote: Something to keep in mind about coding physics engines (and other things like that): it's more effective to have a science specialist learn coding in order to apply expertise to a program than it is to try to teach the scientific expertise to someone who purely knows how to code.
For a simple 2d engine this may not be the case, but it is true in the 'working world' for the most part.
Thank you for sharing this... sounds interesting.
edit: you might want to suggest how people can learn the physics necessary to come up with their own engines! We can't all have degrees in physics :p I would tend to agree. Most people aren't capable of writing this sort of thing on their own. And the funny thing is, is that in 2D the complexity isn't all that much simpler than in 3D. They are actually very similar, and often times just "adding another dimension" is all that is required to make such a transition.
However scientists and mathmaticians are absolutely terrible at programming. They can't really be used for any commercial products because of this. So what is really needed, is someone that is great with mathematics and specializes in computer science. These types of people however are quite rare.
|
On March 28 2013 11:23 CecilSunkure wrote:Show nested quote +On March 28 2013 11:11 micronesia wrote: Something to keep in mind about coding physics engines (and other things like that): it's more effective to have a science specialist learn coding in order to apply expertise to a program than it is to try to teach the scientific expertise to someone who purely knows how to code.
For a simple 2d engine this may not be the case, but it is true in the 'working world' for the most part.
Thank you for sharing this... sounds interesting.
edit: you might want to suggest how people can learn the physics necessary to come up with their own engines! We can't all have degrees in physics :p I would tend to agree. Most people aren't capable of writing this sort of thing on their own. And the funny thing is, is that in 2D the complexity isn't all that much simpler than in 3D. They are actually very similar, and often times just "adding another dimension" is all that is required to make such a transition. However scientists and mathmaticians are absolutely terrible at programming. They can't really be used for any commercial products because of this. So what is really needed, is someone that is great with mathematics and specializes in computer science. These types of people however are quite rare.
I think collision detection or arbitrary shapes is a bit harder in 3d than in 2d, but a lot of the concepts are the same.
|
On March 28 2013 11:41 jrkirby wrote:Show nested quote +On March 28 2013 11:23 CecilSunkure wrote:On March 28 2013 11:11 micronesia wrote: Something to keep in mind about coding physics engines (and other things like that): it's more effective to have a science specialist learn coding in order to apply expertise to a program than it is to try to teach the scientific expertise to someone who purely knows how to code.
For a simple 2d engine this may not be the case, but it is true in the 'working world' for the most part.
Thank you for sharing this... sounds interesting.
edit: you might want to suggest how people can learn the physics necessary to come up with their own engines! We can't all have degrees in physics :p I would tend to agree. Most people aren't capable of writing this sort of thing on their own. And the funny thing is, is that in 2D the complexity isn't all that much simpler than in 3D. They are actually very similar, and often times just "adding another dimension" is all that is required to make such a transition. However scientists and mathmaticians are absolutely terrible at programming. They can't really be used for any commercial products because of this. So what is really needed, is someone that is great with mathematics and specializes in computer science. These types of people however are quite rare. I think collision detection or arbitrary shapes is a bit harder in 3d than in 2d, but a lot of the concepts are the same. Yeah that's one area that gets more difficult. Another one is friction.
|
On March 28 2013 11:23 CecilSunkure wrote:Show nested quote +On March 28 2013 11:11 micronesia wrote: Something to keep in mind about coding physics engines (and other things like that): it's more effective to have a science specialist learn coding in order to apply expertise to a program than it is to try to teach the scientific expertise to someone who purely knows how to code.
For a simple 2d engine this may not be the case, but it is true in the 'working world' for the most part.
Thank you for sharing this... sounds interesting.
edit: you might want to suggest how people can learn the physics necessary to come up with their own engines! We can't all have degrees in physics :p I would tend to agree. Most people aren't capable of writing this sort of thing on their own. And the funny thing is, is that in 2D the complexity isn't all that much simpler than in 3D. They are actually very similar, and often times just "adding another dimension" is all that is required to make such a transition. However scientists and mathmaticians are absolutely terrible at programming. They can't really be used for any commercial products because of this. So what is really needed, is someone that is great with mathematics and specializes in computer science. These types of people however are quite rare.
Do software firms that do a lot of physics modeling (like game companies) hire physicists as consultants, or anything like that? I can understand physicists not being the best at programming, but as far as I know, many of them at least know the basics of coding, and could advise programmers on more efficient ways to implement physics problems.
I took a scientific computing class that was pretty much a mix of physics and CS majors, and the CS majors had devised some of the most unwieldy and awkward numerical techniques to solve problems that can be simplified with math because they simply didn't know how, it was pretty ugly. The physics majors, of course, had ugly and poorly-organized code, so it's not like we were any better, but when we worked in pairs, we ended up with some pretty solid work, considering the level of expertise we were at.
|
On March 28 2013 12:06 corpuscle wrote:Show nested quote +On March 28 2013 11:23 CecilSunkure wrote:On March 28 2013 11:11 micronesia wrote: Something to keep in mind about coding physics engines (and other things like that): it's more effective to have a science specialist learn coding in order to apply expertise to a program than it is to try to teach the scientific expertise to someone who purely knows how to code.
For a simple 2d engine this may not be the case, but it is true in the 'working world' for the most part.
Thank you for sharing this... sounds interesting.
edit: you might want to suggest how people can learn the physics necessary to come up with their own engines! We can't all have degrees in physics :p I would tend to agree. Most people aren't capable of writing this sort of thing on their own. And the funny thing is, is that in 2D the complexity isn't all that much simpler than in 3D. They are actually very similar, and often times just "adding another dimension" is all that is required to make such a transition. However scientists and mathmaticians are absolutely terrible at programming. They can't really be used for any commercial products because of this. So what is really needed, is someone that is great with mathematics and specializes in computer science. These types of people however are quite rare. Do software firms that do a lot of physics modeling (like game companies) hire physicists as consultants, or anything like that? I can understand physicists not being the best at programming, but as far as I know, many of them at least know the basics of coding, and could advise programmers on more efficient ways to implement physics problems. I took a scientific computing class that was pretty much a mix of physics and CS majors, and the CS majors had devised some of the most unwieldy and awkward numerical techniques to solve problems that can be simplified with math because they simply didn't know how, it was pretty ugly. The physics majors, of course, had ugly and poorly-organized code, so it's not like we were any better, but when we worked in pairs, we ended up with some pretty solid work, considering the level of expertise we were at. Not that I know of. Usually companies just use a pre-made engine (Havok or something), or hire people who are very good at physics and math and specialize in computer science. For example Erin Catto does all the physics at Blizzard all on his own. All of it. That guy however is a mathematician and an excellent computer scientist. Also, physics engine development is very low in demand. Studios have like, one guy that does it and usually this guy has been doing it for years and years. It's sort of like engine architect, or technical director; very strong professionals take these positions, and there's almost no demand for positions like such to be filled.
tldr; physics programming isn't a job position that has any demand (in my own opinion).
It is quite interesting to hear about you guys working together though! Honestly computer scientists should have an excellent understanding of math in order to be a competent game developer. Like I said, people who are good at both sides of the fence are really rare, which is why it's so hard for most programmers to get a game industry job related to computer science.
|
On March 28 2013 12:15 CecilSunkure wrote:It is quite interesting to hear about you guys working together though! Honestly computer scientists should have an excellent understanding of math in order to be a competent game developer. Like I said, people who are good at both sides of the fence are really rare, which is why it's so hard for most programmers to get a game industry job related to computer science.
Oh, they knew the math, they just didn't really know the various ways to apply it to physics. One of the problems we did, for example, involved the Coriolis effect, so I got to introduce my partner to non-inertial reference frames and all that fun stuff, which cleaned up the actual computation by quite a bit. He could follow the math easily as I showed it to him, he just wouldn't have thought of approaching the problem that way, I guess.
That kind of sucks to hear about how (relatively) unimportant physicists are in game development, though. It's not surprising, but I guess a part of me was hoping that every game company secretly had a team of top-flight physicists stashed away in a dank basement somewhere.
|
On March 28 2013 12:29 corpuscle wrote:Show nested quote +On March 28 2013 12:15 CecilSunkure wrote:It is quite interesting to hear about you guys working together though! Honestly computer scientists should have an excellent understanding of math in order to be a competent game developer. Like I said, people who are good at both sides of the fence are really rare, which is why it's so hard for most programmers to get a game industry job related to computer science. Oh, they knew the math, they just didn't really know the various ways to apply it to physics. One of the problems we did, for example, involved the Coriolis effect, so I got to introduce my partner to non-inertial reference frames and all that fun stuff, which cleaned up the actual computation by quite a bit. He could follow the math easily as I showed it to him, he just wouldn't have thought of approaching the problem that way, I guess. That kind of sucks to hear about how (relatively) unimportant physicists are in game development, though. It's not surprising, but I guess a part of me was hoping that every game company secretly had a team of top-flight physicists stashed away in a dank basement somewhere. Okay well it's good that he could follow the math!
Yeah, they don't hire straight physicists as far as I know. Of course there's no reason why you couldn't pursue such a job yourself. There'd just need to be a lot of independent study done on your part.
|
Haha nice. Is this going to be the next CryEngine 4?
|
United States24483 Posts
Lots of physicists become solid programmers. In fact, many people major in physics then go on to become software engineers. Others use programming in finance, astronomical modeling, etc.
|
On March 28 2013 13:02 wptlzkwjd wrote: Haha nice. Is this going to be the next CryEngine 4? Haha probably not! However it will be used next year in a game I'm devoting a year of my life (at least one year, maybe two) to
|
On March 28 2013 12:02 CecilSunkure wrote:Show nested quote +On March 28 2013 11:41 jrkirby wrote:On March 28 2013 11:23 CecilSunkure wrote:On March 28 2013 11:11 micronesia wrote: Something to keep in mind about coding physics engines (and other things like that): it's more effective to have a science specialist learn coding in order to apply expertise to a program than it is to try to teach the scientific expertise to someone who purely knows how to code.
For a simple 2d engine this may not be the case, but it is true in the 'working world' for the most part.
Thank you for sharing this... sounds interesting.
edit: you might want to suggest how people can learn the physics necessary to come up with their own engines! We can't all have degrees in physics :p I would tend to agree. Most people aren't capable of writing this sort of thing on their own. And the funny thing is, is that in 2D the complexity isn't all that much simpler than in 3D. They are actually very similar, and often times just "adding another dimension" is all that is required to make such a transition. However scientists and mathmaticians are absolutely terrible at programming. They can't really be used for any commercial products because of this. So what is really needed, is someone that is great with mathematics and specializes in computer science. These types of people however are quite rare. I think collision detection or arbitrary shapes is a bit harder in 3d than in 2d, but a lot of the concepts are the same. Yeah that's one area that gets more difficult. Another one is friction. Yep, friction's a bitch.
The thing about mathematically demanding computer science projects in a commercial environment is that most of the math has already been figured out, and algorithms can be found in research papers or for more generic problems, on the internet. If you've taken the required math for a CS degree at a UC it's not very hard to determine how to properly implement these solutions. Game engine physics require a good bit of science knowledge as well as good programming skills and complete control of whatever language you're writing in to get it right. The physics engine in games needs to run in real-time and be consistent. This means the "correct" mathematical solution might not work because it runs too slowly, so you need to modify it to run quicker without losing too much accuracy. This makes a giant mess if you don't completely understand the math, the physics, and the programming. Bringing together just 2 of the three disciplines is pretty manageable, but all three require a very specific skill set and lots of experience to get right. The place where these skills are the most valuable i probably in medical simulation research facilities, and I think there's a lot more jobs out there for people with this skillset than you might think, but you're correct in that they aren't in the entertainment industry.
|
Katowice25012 Posts
On March 28 2013 13:04 micronesia wrote: Lots of physicists become solid programmers. In fact, many people major in physics then go on to become software engineers. Others use programming in finance, astronomical modeling, etc.
My brief experiences in academia have lead me to believe this is a really smart career move. In all the labs I've worked with or had friends in they were constantly looking for people who could program with the tools they had to get the kinds of simulations and models they needed for publications, making the guys who knew both the science aspect as well as the technical side really valuable. I'd guess that someone who is highly skilled in mathmatics as well as being a good computer science specialist has a lot of opportunities so they don't often land in video games (which I guess would explain why there are a few well known engines out there that handle most of it this for the majority of studios).
|
On March 28 2013 13:02 wptlzkwjd wrote: Haha nice. Is this going to be the next CryEngine 4?
I would so play a 2d crysis platformer. Someone please do this and post to cryengine developer forum...
Seriously though, nice work cecil, I really appreciate that you spend the time to create the educational content, especially since I've moved from the CS academic world to a digital media and design trade school.
Teaching others what you have learned ensure you won't forget it, this has been shown in many studies, keep up the great work!
|
Ah this lead to a cascade of link clicking and article/blog reading, resulting in the consumption of many tasty tidbits of useful info I had not come across before. Thanks!
|
Correct me if I'm wrong, but the issue with physics coding is more often than not the game engine doesn't actually code for physics, so much as it codes the "effects" of physics, if you know what I mean.
|
On March 28 2013 12:15 CecilSunkure wrote:Show nested quote +On March 28 2013 12:06 corpuscle wrote:On March 28 2013 11:23 CecilSunkure wrote:On March 28 2013 11:11 micronesia wrote: Something to keep in mind about coding physics engines (and other things like that): it's more effective to have a science specialist learn coding in order to apply expertise to a program than it is to try to teach the scientific expertise to someone who purely knows how to code.
For a simple 2d engine this may not be the case, but it is true in the 'working world' for the most part.
Thank you for sharing this... sounds interesting.
edit: you might want to suggest how people can learn the physics necessary to come up with their own engines! We can't all have degrees in physics :p I would tend to agree. Most people aren't capable of writing this sort of thing on their own. And the funny thing is, is that in 2D the complexity isn't all that much simpler than in 3D. They are actually very similar, and often times just "adding another dimension" is all that is required to make such a transition. However scientists and mathmaticians are absolutely terrible at programming. They can't really be used for any commercial products because of this. So what is really needed, is someone that is great with mathematics and specializes in computer science. These types of people however are quite rare. Do software firms that do a lot of physics modeling (like game companies) hire physicists as consultants, or anything like that? I can understand physicists not being the best at programming, but as far as I know, many of them at least know the basics of coding, and could advise programmers on more efficient ways to implement physics problems. I took a scientific computing class that was pretty much a mix of physics and CS majors, and the CS majors had devised some of the most unwieldy and awkward numerical techniques to solve problems that can be simplified with math because they simply didn't know how, it was pretty ugly. The physics majors, of course, had ugly and poorly-organized code, so it's not like we were any better, but when we worked in pairs, we ended up with some pretty solid work, considering the level of expertise we were at. Not that I know of. Usually companies just use a pre-made engine (Havok or something), or hire people who are very good at physics and math and specialize in computer science. For example Erin Catto does all the physics at Blizzard all on his own. All of it. That guy however is a mathematician and an excellent computer scientist. Also, physics engine development is very low in demand. Studios have like, one guy that does it and usually this guy has been doing it for years and years. It's sort of like engine architect, or technical director; very strong professionals take these positions, and there's almost no demand for positions like such to be filled. tldr; physics programming isn't a job position that has any demand (in my own opinion). It is quite interesting to hear about you guys working together though! Honestly computer scientists should have an excellent understanding of math in order to be a competent game developer. Like I said, people who are good at both sides of the fence are really rare, which is why it's so hard for most programmers to get a game industry job related to computer science.
hehe I use Catto's 2D physics engine in all my 2d games
|
On March 28 2013 12:15 CecilSunkure wrote: tldr; physics programming isn't a job position that has any demand (in my own opinion). Like micronesia said, a physics programming is the mother of all computational science bar computational mathematics (but mathematicians are always secluded). Weather forecast, Finance, behavior modelling all of this is done by physicists.
For example, the best programmers in my theoritical physics class have written projects like : behavioral spreading of diseases, chaotic rebound (that was mine) or weather propagation. Those were simplistic but for most of us that was our first real code ever and we all wrote in C.
|
I'd love to see more of this. I am a programmer both working for a webdesign studio and freelancer and always like to learn more about these subjects. Eventually I would love getting more known in using science in websites.
Good luck!
|
|
|
|