@@kaibaman9651 That is not true. Game Engines do most of the mathematical work for you and you rarely ever need to use complex math and even if you do have to use it there are most likely people out there who are glad to help you. Not everyone is perfect everything but that does not mean you shouldnt try anyway. I personally suck at drawing and i still do it every single day, if you dont practice you wont improve. Now go and make a game :D
@@raypuiaascii4653 ive heard 256mb (megabyte not megabit) but ive also heard up to 4gb im not sure which one is true. wile this is possible on emulator its currently not possible on any current flashcart cause of the limited 64mb of ram it loads a rom into. unless everdrive releases an updated cart 64mb this is the max.
babe wake up vertex shaders for the n64 just dropped vertex animations are actually used quite a lot today for foliage wind and deformation for example, the hardest part to do full animations is baking them to work with closed meshes though, but it does get used sometimes today, rat shaders are great haha
I’d love it if Mario 64 and innovative games on old hardware could be explained as lessons honestly, I feel like it would make for a much more interesting curriculum.
When I was learning about matrices in class I saw the phrase computer graphics during the introduction lesson and that prompted a neuron activation The rest of the topic was just doing operations between matrices in a vacuum, and occasionally some problems with 2D shapes. My disappointment was immeasurable
I took a graphics programming course in college, and a lot of the students had trouble understanding what the view matrix does. The infamous "the camera doesn't move, the whole world moves". I understood it because I knew that's just how it's done even in 2d games, but without a visualization of how it transforms the world to be "in front" of the camera many people struggle to understand what it does. But I suppose knowing you need to feed it the camera's coordinates inverse is a good enough understanding to get it to function as expected without needing to understand the math.
I was taught how this stuff works in my computer visions course of my Computer Science degree. Despite having zero previous knowledge of anything taught, I thought, when you took 3D rendering as actually just kinematics transformations, it all made intuitive sense. I'm rather surprised you said people had issues with that. its pretty simple Maths.
@@fearedjames Idk, maybe the way I remember it is just an exaggeration, but I do remember some students reactions to the lesson, and that "There is no camera" became kind of a meme, so much so that any time our professor used the word "camera" during a lecture, students would chime in and say "But I thought you said there is no camera" as a joke. I don't want to sound arrogant, but I did graduate top of my class with only 92% overall average, which isn't even that high for top of the class imo. Perhaps most of the students had trouble with the program in general? It's worth noting too that college here in Canada isn't the same thing as university, and university is usually regarded as the harder academic path, and it's the most encouraged in secondary school.
so... I actually specialized in 3D computer graphics engines in my computer science days (graduated in 2008, around the time when you still needed to really optimize things). literally everything (shaders, motion, projection, screen space, world space) in an engine is a matrix by nature of simply needing to transform mathematics in a 3D space. the problem isn't that some of these engines aren't using matrices (they are), it's that they've been heavily abstracted into engines that allow for more rapid development at the cost of things like "5 FPS background characters" that few people will notice or care about, certainly not at the risk of a launch delay. it's like choosing to write your program in C++ or assembly - you're going to have much finer control over your performance, but at the cost of development time. I realize I'm speaking on a channel dedicated to hyper-optimization, but that just isn't the way product development can work in the real world.
yeah i talk about how all engines i know use matrices too. my point is that devs underutilize them. c++ vs assembly is unfair comparison imo - assembly takes at least 4-5 times as long to develope and most hand written eassembly can't compete with compiler generated assembly. it's a lot less practical. abstracting stuff and cutting dev time is great, just not when there are such huge drawbacks to it imo
7:35 The reason the W component is special is because when: W=1 the vector represents a point W=0 the vector represents a direction (remember to normalize all vectors to be unit vectors so you don't run into transformation bugs) Edit: 1. *Note:* This ONLY applies to the NON projection matrix. 2. Anyone wanting to understand the projection matrix should read Eric Lengyel's excellent *Projection Matrix Tricks* pdf.
This understanding breaks down at the projection matrix. All perspective projections will mix the Z coordinate into W at some point, which gives you all sorts of values for W. This works because W is a scaling factor: the coordinates we're working with are called homogenous coordinates. To convert back to standard coordinates you have to divide out W from all other components. We work in this coordinate system because perspective is not a linear transformation and thus cannot be represented by matrices alone. Matrices can only scale by a constant, not by other coordinate values, but adding W fixes that. If you adopt the convention that W=1 for points, then you can also represent translations as a matrix. This is why you always set the W column of a transformation matrix to identity. When Kaze started playing around with the W column, he was both turning Mario into a frustum as well as rescaling any transformations on individual Mario verticies done after that matrix. (If for some reason you really wanted to transform things into frustums with your matrices, you could divide out W and reset it to 1 at specific steps to keep transformations stable, but then you can't multiply your matrices across the division.) W=0 divides by zero. If your game and renderer / GPU works in floating point, that gives signed infinities for the other components of the coordinate. If you were to change some points on a model to W=0 (and your hardware is OK with rasterizing this) you'd have a model whose polygons blend into the background.
@@SuperSmashDolls Excellent summary! Eric Lengyel has an fantastic *Projection Matrix Tricks* pdf that should be required reading for anyone interested in this topic. I'll edit my comment with an Caveat that this only applies to the non-projection matrix.
Another very good video. 7:31 If you want to know more, this is for you: Because 4x4 3D transformation matrices are basically just four homogeneous 3D vectors (so 4 components: x, y, z, w), the last column in this image is the w components of the row vectors. The w component is used to do two things at differnet stages of the 3D transformation pipeline: 1. On the input side it is what makes the vectors and matrices homogeneous. What does that even mean? It allows us to use the same computations on two distinct types of vectors that look the same (encoded into a 3 component 3D vector), but behave differently. On one hand you have positions that should scale, rotate and translate; on the other you have directions which should only scale and rotate. Instead of having to implement all operations twice to handle each type of vector, you can add another component to everything and select the type of vector by either enabling or disabling the translation part of the matrix. Where is that? It is the fourth row. The other three rows are each the scaled direction of the local X, Y and Z axes in that order. All four components usually combine into a orthographic (right angles between all three axes, with scaling; no scaling would be orthonormal) basis, giving us a local object space in which we can work and is called the "model matrix." Incoming vectors are basically just weights that are applied to the matrix's four vectors before they are all added up to yield a new outgoing vector. Therefore a position has its w set to 1 and a direction has it at 0. This means the former receives the translation from the fourth matrix vector, while the latter doesn't, as the matrix's vector is multiplied by 0, resulting in an offset of all 0s that doesn't change the result after addition. This is how the introduction of w changes the two distinct (heterogeneous) types of vectors into a common (homogeneous) one. View matrices are the same as model , but are constructed slightly different. Projection matrices use the same format, but mostly just apply screen space XY scaling around a focal point proportional to the computed depth of each position vector. 2. On the output side of the transformation, w contains a perspective correction factor that is used in the "perspective divide" operation to shift any interpolated attributes according to the depth gradient across the transformed surface. It fixes the texture warping that was present on early 3D game consoles like the PS1 (N64 had this built-in already, so its games did not suffer from such warping). Division is still somewhat expensive (albeit casually usable) these days and it was even more so in the early to mid 90s, thus skipping the perspective divide for each computed fragment (pixel-sized piece of a surface) was an easy way to make 3D graphics faster and chips cheaper with some trade-offs back in the day. Some classic games like System Shock 1 had several degrees of perspective correction in its settings on PC. w also has other uses, e.g. as an alternative to z for depth buffering. The output's z contains the non-linear depth, whereas w has the linear depth. Some consoles supported both types of depth buffering in hardware like the NDS. z depth has more precision close to the camera, but suffers from precision loss which shows up as flickering known as depth fighting. w depth has uniform precision and therefore less flickering, but it can suffer from precision loss close to the camera compared to z depth. The last point is rarely an issue in practice and the very far view distances without too many weird hacks are worth solving any near field precision loss.
@@KazeN64Its true! One time I programmed a game, and one of my players came up to me at McDonald's and spat in my face (Traumatic) saying I'd never be a real game dev until I learned rendering matrices Suffice to say I've never gone back to McDonald's
This is an excellent primer to matrices especially for beginner-intermediate gamedevs, it's super useful to know this information especially if you're working with more framework-y engines (or no "engine" at all!) where you have an insane level of control over what happens at different stages (but even if you're using a super batteries included engine it's still excellent knowledge for the future!)
The perspective part of the matrix could theoretically be used to achieve a Link Between Worlds effect where you render everything at an angle to give that classic "top-down" view using 3D graphics
@@tbtb66 you need more than just matrices for animal crossing because matrices only do linear transformations, whereas making a curved world is not linear
@@henrycgs "Theoretically" meaning you could use it to achieve the same effect in a N64 game. Not sure how useful it would be in a 3D platformer without some very clever level design... maybe if you wanted to do a Crash Bandicoot style running towards the screen level?
I'll be taking the time to read through all the comments and feedback on the editing. I appreciate everyone who shares their thoughts and suggestions! 🙌🤗
It's already been said many times, but the sound effects for every little thing was too much. It reminds me of an over-edited RU-vid short trying to hold my attention.
the intro cards for topics and things were very nice, and a lot of the additional animations and things i liked. i think maybe too many sound effects though. overall i like the direction great job
I actually understood it pretty well. It's essentially coordinate plane stuff,but 3D, so add a Z-Axis. Tell the model/effect how to move without adding a gif or animation and it's kuch cheaper than calling an entire animation as it's done in the code, not calling anything. Was that simple enough?
@Daltonisntabot A different way of putting it is that it's tweaking the parameters of how 3D meshes are being projected/flattened onto 2D space. This step already has to happen as part of the rendering pipeline, which means there's no added cost to have scale/shear/rotation effects other than the cycles spent tweaking the parameters.
it's high school math. keep doing math and you'll get there! unfortunately they may teach it to you in the most boring way possible. in my experience, it's much more interesting when you're using geometry and linear algebra for graphics or game physics. if you're really interested in game math and graphics, another good creator is Inigo Quilez. He's the creator of shadertoy.
7:29 From my memory, the last column can be used for custom projection. Usually the projection is done on a near-plane that is perpendicular to the camera's view direction. Changing these values allows you to do things like Portals, where you need the projection plane to be the same plane as the wall you're looking at.
I've been out of the loop, I learned matrices as the primary means of controlling and projecting 3D objects for my degree. I'd always taken it to be THE WAY. It would be very interesting to see how the new HITMAN games 1-3 handle their NPCs. They have large crowds that still react to your actions (in a more limited way than "important" NPCs but still extensive) and, have seemingly little impact on performance, even in great numbers. Would be very curious to learn the optimisations for them.
Likely LOD (Level of Detail) for far away objects. Less geometry & bone count = less vertex transforms. Another technique (usually used static objects) is “imposters” where you render a 3D model to a texture and show the 2D image.
That's why HITMAN is so interesting, LOD would be useful but you're often very close to huge crowds so they must still be very efficient regardless. I don't think they are 2D imposters either as you can physically interact with them. Reason I thought of them for this video is many of them share the same models so I'm wondering if they are perhaps clones of each other with different transforms applied for idle animations until they become "disturbed" (by you shooting them or something similar nearby). At which point it's as if they "come to life", like they've now been assigned more complex animations and AI instructions. Most stand around while only a few "decide" to start walking around. I don't know how that's done but I'd opt for an NPC selector that runs on a schedule, regularly picking from the list of super simple NPCs based on some conditions and then assign more complex behaviors to them.
The w part of the matrix is used in the final projection by doing "xyz / w". This is where the difference between orthographic and perspective projection matrices come in. Orthographic forces it to be a 1 while perspective uses z for it.
Dude the editing in this video is absolutely SUPERB, and represents what I wanna do with my own videos. Also, great explanations, I learnt a lot today !! :D And your game is actually looking VERY nice, I especially love the orangey tones of the oil rig level a LOT !! Keep up the great work, mate !!
Dual quaternions are pretty great. They're half the size of a 4D matrix, and depending on some specifics, they can be cheaper to compose than matrices (though the also might not be since matrix multiplication is easier to roll into a loop). Applying them to vertices is more expensive however and usually you just convert it into a matrix at that point. Also, dual quaternions can't represent shears, which can be a good thing in many contexts, though Kaze seems to be using shears intentionally here, so they wouldn't help, and can't do scaling (uniform _nor_ non-uniform), which again, _can_ be a good thing depending on the kind of style you're using, but would probably be more of a drawback here. I'd still love to see Kaze consider at least regular quaternions. (They do _not_ require wrapping your head around 4D geometry; they are merely mixtures (aka weighted sums, aka linear combinations) of 4 basis 3D rotations: 3 180° rotations around the original axes, and a 0° rotation around... everything and nothing.)
I just finished an overview of matrix multiplication in my Discrete Mathematics course I'm taking, so you can't imagine how giddy I was seeing concepts I just learned being applied practically in this video. Love it!
It’s interesting that this is presented as some kind of arcane magick. In a course you come across this pretty quickly, and is why they generally require linear algebra. I guess while the end goals might be the same, the starting points are a bit different
God where were you when I flunked out of linear algebra back in college? This video could've carried me thru that semester lol. Great video, love your work!
There's a few other things you can do with render matrices that I'm aware of. One of my uses of them was to emulate arbitrary rotated and placed clip planes on hardware/with game engines that do not support these. Another one is to use them for super-resolution screenshots by subdividing the final rendering matrix, allowing you to make screenshots well beyond the 64kx64k limit. They're super powerful, and extremely cheap to run. Also AFAIK modern games still use bone based animations, but the number of vertices that need to be modified has gone up significantly. In Unreal Engine for example, you can opt in to GPU skinning, which significantly improves performance if you're CPU bound, but hurts it if you're GPU bound. The problem that modern games have is that their LoD choice is often not great for the hardware it is going to be running on, resulting in unusual performance losses. And for some reason, the default has now become to make the animations worse - treating the symptom instead of the problem.
m64 associates each vertex with only a single bone. modern games use a mapping of 1 vertex to N bones (often 4, I believe), with a decimal value weighting how much each mapped bone contributes to the vertex's position. while modeling, the process of associating bone weights to each vertex is called "weight painting". "hurts it if you're GPU bound". It depends on how much CPU -> GPU memory bus bandwidth you're using. streaming bone transforms from RAM to VRAM can be much cheaper than streaming vertex data, since the vertex data can just be transferred the one time in bind-pose. so it's not just the amount of CPU/GPU compute that you may have a bottleneck on. bus bandwidth also matters. of course that might be old information now too, and we might have very different results once you start factoring in dynamic LOD stuff like nanite.
"The problem that modern games have is that their LoD choice is often not great for the hardware it is going to be running on, resulting in unusual performance losses. And for some reason, the default has now become to make the animations worse - treating the symptom instead of the problem." Or lowering the rendering resolution, making distant the objects that they were so desperate to render a blurry mess of pixels that would have been better off culled entirely or replaced with a lower LoD. I know this likely won't work for multi-platform games, but if there is only a single target platform, surely it can't be that hard to set performance targets and then make sure the artistic vision for the game works within those constraints?
A really convenient use of transform matrices is that you can easily determine the up, forward, and right of an object just by pulling any of the 3 rotation vector3s of the transformation matrix! I'm sure modern game engines already provide helper functions for that, but it's especially useful when working with more primitive engines like Mario 64.
6:21 Unfortunatly ROBLOX tries to prevent you from doing this for some reason, likley because it would break the physics engine, or because the physics engine doesn't see the sheer so it removes sheer and keeps rotation on physics update. OR ITS ROBLOX'S ANNOYING ORTHONORMALIZING! D: Atleast you can still sheer the camera in ROBLOX.
i really love the blending of the skybox and the levels edge, it really makes your levels look much much larger. definitly add this to all your levels its beyond cool and clever
The "3D Math for Games" section in Jason Gregory's (Naughty Dog Engine developer) book "Game Engine Architecture" is an amazingly helpful read that's related to this! Especially the matrices section.
This is utterly fascinating, and I have a vague idea what's going on here... but I'm never gonna hit this level. As a game dev, I'd like to put this DnD wizard-based analogy: I'm having fun with some cantrips and the odd casting of Fireball. Kaze is explaining how you, the viewer, can cast Wish and Time Stop with enough experience!
Lovely work as always, personally I think I’ll be in the minority by saying no to a demo….because I just know the finished game will be amazing I won’t want that wow factor to be diminished by getting a taster early! 😂
I remember having a really hard time in college understanding the matrix math involved with graphical rendering. Really thankful to have this quick intuitive guide if I ever dive into that again!
Liking this video as soon as you showed the Matrix changing while the values were displayed on the screen. Super useful when trying to understand the math behind the results and it opens for deeper looks into it in general. Great video in general
4:20 There's a company called Voxon Photonics that makes 3D displays. No sure how many people have one of those though, but it's 2D once it reaches the retina
Patricia [The new word for matrices] Are just good to know in general, there's a reason why linear algebra is required to get a CS degree. (For some reason, computational science and linear algebra are really closely tied together in more ways than just 3D graphics)
A TA (technical artist) / rendering engineer here. 2:30 Actually, on modern hardware (anything less then 10-15 years old) it's *MUCH* cheaper to animate BG characters fully on GPU. The only thing CPU does in such case is it sets up each charcter's animation ID and progress (which can be sent as a single massive buffer with all animation states for all the characters at once). Animation itself is then done via GPU only. Check out VAT (vertex animation textures) technique or, for even fancier approach, check out how rendering is done in Alan Wake 2.
Yeah absolutely!! I implemented VAT myself before. I believe by default out of the box, UE5 animated characters on the CPU though, which is that much more expensive. And if you went with matrix animations like this (imagine only supplying a handful of quaternions and offsets and then it computes a matrix stack applied to all individual body parts), i'm sure it'd be even slightly cheaper than VATs. Both easily beat the CPU animations in most cases though I think
@@KazeN64 VATs themselves can contain rotation quaternions per-joint (not per-vertex), while vertices contain onle their corresponding joint IDs. That's how VAT export is by default implemented in modern Houdini. And you can atlas multiple VATs together (or put them into texture array) - thus, getting an entire animation set in a single texture, which would let you draw all the characters with this animation set (and possibly, even slightly different models) in a single draw call. But, of course, that Houdini's general-purpose tool isn't tailored for BG charcaters specifically. For those, as always, you'll need to make a custom VAT exporter yourself. But my point is, for large crowds of BG characters, I don't think the technique shown in the video is "much cheaper than modern animation techniques". Since VAT is, technically, one of those. It's definitely cheaper than a *default* animation technique used in any engine (not nonly UE5, Unity too). So laggy characters in modern games isn't a testimony against modern animation techniques, it's a testimony against low-effort development.
Makes sense, so a lot of games already use something very similar here, it's simply not the default. Still wish more games did it the more performant way
This feel like the equivalent to the SNES sprite distortions. The effects look good! (I mean graphically, I imagine that technically it is more complex than that)
I’m not a game dev, I’m a computer scientist- we hit on all of this stuff in my very first and only computer graphics class that I took out of interest. I would be very scared if game devs that went to college somehow didn’t know this stuff.
A lot of game devs A) don't have a college degree in computer science and B) use the standard Unity settings without giving graphics a second thought. Does this mean they're not real game developers? No.
@@General12th a) if you try to do gamedev then you'll run in to this stuff in no time. Doesn't matter if you have a degree or not. So for this reason alone, I cannot believe that there are gamedevs(on the programming side) out there who are unaware of what matrices are and what they are used for. Unless you count anyone who installs unity on their computer as a gamedev. TBF, in a world where people who write prompts for AI's think they are making art nothing like that surprises me anymore. b) matrices are all over the place: transforms, coordinate systems, animation. It's not a graphics thing.
@@Bestmann3n I'm a pro game dev. Not all pro game devs are that good at these things, and often get away with calling functions that do most of the work for them. A lot of game programming is bookkeeping of game rules and GUI logic, and not geometry or linear algebra. It really depends on what kinds of games you're making, and what your specific programming role is in the company. The more a "generalist" the person is, the more they'll probably just fudge the math until they get roughly the result they want, without necessarily having a strong grasp on what they did. Quite common in indie games, where they have to wear all the hats. But yeah, it's fairly common to know these things, especially if you were around before the time that Unity/etc were ubiquitous.
Unfortunately the game dev industry is propped up by a ton of fraud and fake knowledge sloshing around in degree programs. There's a ton of untalented and uninspired game devs wasting space. Engineers vs people who read a textbook and were able to reproduce information they hardly understood for a multiple choice exam that gave retakes if they failed
I did a minor once where I had to make my own little DirectX render thing and now I understand Matrices a little more. But a lot of the rest was familiar. Wowie!
0:48 Certainly! I used to just find the angle and distance a point was at then add to the angle and use sine and cosine to replot the point... Rotation matrices are an invaluable tool!
I used them in a game for a game jam I took part in on my second channel. Projected a flat world onto a “sphere” (it was actually a parabolic shape but I’ve since turned it into a real sphere). Worked really well!
The production values on your videos have exploded exponentially and yet you've managed to keep them concise, informative, and effortlessly entertaining without succumbing to all the obnoxious filler crap that normally ruins channels once they find their rhythm. Keep up the great work!
I'm learning applied linear algebra for games through an online textbook! The power of matrices are amazing and I'm glad you're highlighting their utility in this video :)
I'm amazed by how much research and developments you invested into this console! In fact, it reminds me of how much I invest into my animation rig with all the discoveries I made.
This is extremely well done summary of matrix math as used in 3D graphics given a target audience of people who knew this once upon a time and forgot it. If it's your first time seeing a matrix... well understand this would usually be 1-2 lectures (ie a full week) of a college level course, so of course it's hard to follow when condensed into 10 minutes or less. Plus that college class would typically assume a linear algebra pre-req, tho to be fair very little of that linear algebra class is relevant. I mean, eigenvectors, etc...
Honestly, considering how you said that the opening area is now very different in one of your previous videos I think making a demo showing the more up-to-date game a little bit would be really cool!
Matrix transformations in games actually predates proper 3D rendered graphics. The SNES's Mode 7 graphics mode would use matrix transformations to scale and rotate a 2D plane, and then a psudo-3D perspective could be created by using direct memory access to create a projective transformation while drawing the plane to the screen.
So there is no Matrix in the perspective case (F-zero). Instead you cast rays for both sides of the screen over the floor. You take the scalar 1/y and multiply it with a vector. Then for each scan line you take the delta u and v (or s and t (naming convention?)) and let the hardware add them as it renders left to right.
I was always curious about how the Ocarina of Time cutscenes (especially inside Ganondorf’s tower) accomplished focal length effects, and now I know: it was projection matrix manipulation! So cool!
They way I like to think about matrices => A car is going north, a man sees the car going left, the driver in the car seat is going forward. Matrices are just "perspectives" that can be converted into and unto each other at will.
I love this channel so much. Thank you for all of your hard work & I hope that you have a great weekend. I can't wait to experience your Mario game for the first time. I'm more excited about that coming out than any future game release that I can think of right now
On modern hardware you can also try and leverage vertex animations baked into a texture and sample it with filtering for large crowds of unimportant entities. One mobile game does that for stadium crowd, and some PC games might be doing that for birds. Just don’t forget to add .5 to get the correct unsampled texel.
Kaze Emanuar 4:26 RU-vid's VR View exists, but the video itself has to be recorded in 3d in some way, Meta quest is a 3d output device but there is no 3d input device for recording, unless the use of dll and plugins are used for a game or application
There actually ARE 3 dimensional output devices. They are some weird thick screens where indeed you see something different if you move relative to it, of course it is crazy expensive both in price but of course you also need to compute like 30 images for every single frame so computation is insane.
I wouldn't want, not even background peds, to be modeled/animated this way. Having those sharp edges between the objects would make modern effects like ambient occlusion, make those peds look like the Michelin Bibendum. Maybe for LOD models could still be used, but I don't know if it would be worth generating alternative animations for the different model types, instead of just jumping frames from the main animation like it's common to see now.
9:52 sounds a lot like what Source Engine games do (the Citadel early in HL2, faraway landscapes, etc.). The way they do it is to have a special miniature map and render it in the background at increased scale.