11 ms·
Fundamental Math for Game Developers
- uzbit 4y agoI found bi-vectors[1] to be a really interesting algebra for graphics. Unfortunately, I've not had much use for this kind of math to be able to really dig in. [1]https://bivector.net/ https://bivector.net/
- atan2 4y agoi received this link on my inbox yesterday. it is long but it was worth every line. I am a fan of gustavo's work.
- GalopolisRave 4y agoGreat read! Highly recommended
- pellucide 4y agoI recently did a mobile app which de-warps live video from a fisheye camera. Admittedly, not a game app, but it uses OPENGL and Metal to do the job. I could not have done it without articles like this. I am fan of the way he explains. The scope of his articles go beyond gaming. Thanks Gustavo.
- AlexeyBrin 4y agoCan you give some suggestions of good articles/books about de-warpping live video from a fisheye camera, sounds fascinating. Thanks.
- pellucide 4y agoThis is not a comprehensive answer. Please DM me if you are interested in a longer answer. But the idea was to map the video into a 2d grid(25x25). Map the 2d grid into a half dome 3d model(25x25 vertices). Then divide the flat video into textures that fit into each to the smaller rectangles/triangles on the 3d half-dome. Once you have the 3d model, manipulate it using OpenGl or metal primitives.
- dukeofdoom 4y agoClear Code on youtube is a great channel for beginners
- photochemsyn 4y agoGreat overview, though every one of those topics could be the subject of pages and pages of code and writing. I came across a good book recently that covers much of the material in a somewhat project-oriented way (all Python code, but if you're really motivated you can rewrite them into a more commonly used game language like C++ using SDL2 or similar). Lots of detailed examples and exercises (it's a bit more oriented towards machine learning uses than game engines): https://www.manning.com/books/math-for-programmers https://www.manning.com/books/math-for-programmers
- okaleniuk 4y agoWhat do you think about https://www.manning.com/books/geometry-for-programmers https://www.manning.com/books/geometry-for-programmers ?
- trynewideas 4y ago> every one of those topics could be the subject of pages and pages of code and writing > covers much of the material in a somewhat project-oriented way > Lots of detailed examples and exercises I guess that's why the guy sells a half-dozen 20-40 hour courses from this website which purportedly do that.
- qsort 4y agoArticle is mostly fine, but there's a point I vehemently disagree with: you should not, absolutely not translate math notation to code. Math is equational and declarative. When you write: S = \sum_{i=1}^{100} (2i + 1) you are declaring that we shall call S the sum of the elements of a certain set. You are not prescribing how this sum ought to be calculated: S is a pure value that doesn't depend on what practical operations you do -- be them on paper or on a CPU -- to actually find out what S is. For example, using equational reasoning, we may write: S = \sum_{i=1}^{100} 1 + 2 \sum_{i=1}^{100} i = 100 + (100 * 101) = 101^2 - 1 Or, without computing anything at all, we may prove by induction that: (1) \sum_{i=1}^{n} (2i + 1) = (n + 1)^2 - 1 The base case is obvious, and to prove the inductive step it is sufficient to observe that indeed: (n + 1)^2 - 1 + (2n + 3) = n^2 + 4n + 3 = (n + 2)^2 - 1 From which it follows: S = 101^2 - 1 Tying math to code is more like tying your own hands behind your back. All of this is basically an excuse to point out that the code for the product is wrong, the initial value should be 1 and not 0 (or, in general, your monoid identity).
- ta123456789 4y ago> you should not, absolutely not translate math notation to code. I don't see a problem, if eg it helps with getting some intuition. Sure there is a formula for this example. But the point in the article of writing this sum as a for loop is to explain what the notation means. For a programmer who is not familiar with sigma/pi notation for sum/product, explaining it with a for loop is a quick way to understand.
- SamBam 4y agoExactly, that was my take-away. You don't need to think of the Sum function as a for-loop every time you use Sum, but it certainly helps explain it to a programmer who doesn't have a sense of what Sum is, but knows what a for-loop is.
- cttet 4y agocode != imperative languages, though. There are expressible programming languages/library that can express the same semantic as math.
- djmips 4y agoAnother good resource that has been there for years is https://www.essentialmath.com/index.htm https://www.essentialmath.com/index.htm There are also many tutorials he and others did in the form of GDC talks over the years in the Math for Game Programmers topic. And he has a book. https://www.essentialmath.com/book.htm https://www.essentialmath.com/book.htm
- detrites 4y agoThis is excellent. However, some may feel a large portion on fearing math in school is out of scope (for them). If that's you, after the first few paragraphs of "Our Weird Relationship With Math" skip to "Going Back To The Basics".
- okaleniuk 4y agoI think, there is one more topic a game developer should know about that fell through the cracks. It's computer algebra systems. The rationale is simple. If you want to learn math fast, be prepared that you will stumble upon the lack of training as soon as you go from theory to applications. Normally, you need to go through a few books of exercises to start feeling comfortable with calculus or discrete math. And that's where computer algebra systems step in. They do your math for you. It's much simpler to learn the basics of any CAS than to train yourself to solve all kinds of equations with pen and paper. It's easier (and more fun to be honest) to practice with a CAS and gain experience on the go too. In my book, an introduction to SymPy takes only a few pages, but enables practicing with linear systems, matrix operations, calculus, polynomial approximation and interpolation, Bezier curves, NURBS, and polynomial transformations as the book progresses. And SymPy is not even the most potent CAS out there. It is free and easily accessible though. If you know a little Python, you already know a little SymPy.
- mrmuagi 4y agoAny games that use those systems? I guess games that have lots of simulation calculations?
- strangetortoise 4y agoI might misinterpret the parent, but I think the parents idea is more that it helps when deriving the math used in a lot of video game programming. (e.g. simplifying expressions in shader code, or deriving closed forms for intersection tests). Where this might help is if you don't have a strong background in algrabra, and don't know all the properties of e.g. quaternions by heart. You'd implement essentially the answer that you get after playing with a computer algebra system
- okaleniuk 4y agoYes, exactly! A CAS lends you the skills of a mathematician once you already have the knowledge of a mathematician.
- 4y ago
- friendlyHornet 4y agoThere is an awesome playlist [0] on YouTube called "CodingMath" that I think is perfect for anyone interested in computer-graphics or video game development. I think it's useful for every developer, too. The author uses JS and HTML5 to implement what he explains but you do not need any JS or HTML5 experience to understand any of it and you can recreate all the code in any language. All you need is experience in a programming language [0] https://youtube.com/playlist?list=PL7wAPgl1JVvUEb0dIygHzO4698tmcwLk9 https://youtube.com/playlist?list=PL7wAPgl1JVvUEb0dIygHzO469... Note: I am not associated with the author and haven't watched all the videos in the playlist but watched enough of thwm to recommend it.
- atan2 4y agoCoding Math is really good. I think I've watched most of his(?) videos. Sometimes I think better drawings could help instead of hand-written graphs and diagrams, but the main point gets across.
- jacknews 4y agoI think geometric algebra should be included, maybe even replacing quaternions.
- justincredible 4y ago[dead]
- Rony2022 4y ago[flagged]
- ivansavz 4y agoI like that the author spends time on notation, mapping math concepts to their equivalent in code. In my experience this is a big stumbling block for coders trying to learn math. It's difficult enough for the general audience to learn math notation (alien symbols), but coders face the extra difficulty of "namespace conflicts" for the meaning of math symbols (e.g. = sign does not mean assignment).
- deleted 4y ago[deleted]
- greenhearth 4y agoGreat read! This is what I look for.
- bob1029 4y agoI think the most important kind of math is linear algebra if you are serious about building something from absolutely zero. Achieving mastery over the rendering pipeline requires lots of experience with matrices. Some of the more esoteric stuff might take you multiple papers/books to fully-grok. An example of this for me was clipping of geometry against the view frustum (for building a software rasterizer - GPUs handle this for you now). I've got 3 different papers on this exact topic still sitting on my coffee table. I think the hardest overall aspect is thinking in 4 spatial dimensions and getting your head around all of the transforms. If you are using a 3rd party engine like Unity or Godot, you may find that mastery of this stuff is not as essential. I think it still helps to understand how the scene graph is ultimately rendered, but unless you are building these engines with your own hands, worrying about acquiring this knowledge could be prohibitive to progress.
- atan2 4y agoThis page helped me understand clipping in 4D: https://fabiensanglard.net/polygon_codec/ https://fabiensanglard.net/polygon_codec/
- noam_compsci 4y agoI am unity and what is this
- justincredible 4y ago[dead]
- PointyFluff 4y ago[dead]
- havercosine 4y agoGustavo has created superb courses around Maths and Physics of game development. I did 2 of his courses and RoI in terms of learning is huge. The crucial point is: he starts with an empty file and codes up the stuff with you at an understandable pace, line by line. A lot of concepts I just understood in hand-waving sense became much more clearer after going through this routine. I'm planning to next take his Physics course but maybe code it up in Rust so that I'm not re-inventing some wheels (like dynamic arrays). But if anyone wants to brush up on most important pieces of maths: vectors, matrices, calculus I will heartily recommend his courses.
- gustavopezzi 4y agoAuthor here. Thank you for sharing and for all the constructive comments.