3 ms·
Every time I look at anything about graphics programming, my head implodes. I just don't get it. I don't get how the matrix operations somehow magically work o
by salawat 5y ago
Every time I look at anything about graphics programming, my head implodes.
I just don't get it. I don't get how the matrix operations somehow magically work out. I don't get how it is that light bouncing/reflectivity works itself out in any reapectable amount of time. It all just sounds like a bunch of jargon, jumbled together, and pretty arrangement of pixels comes out.
Like I get the camera being set in a scene. I get it forms a frustrum with everything in the field of view. I get that you have a bunch of geometry in it's own independent coordinate systems, that are then glued together by transformation matricies.
I get U, V, W unwrap basically taking a 2D texture and mapping it to a 3D model. I get annotating fragments with material properties to aid on subsequent processing passes treating using linear trajectories and other Voodoo to figure out where reflections, shadows, and brightening should occur, and that part of what makes all of that doable is massively parallel co-processing devices divide and conquering the processing, which are orchestrated from the host system's memory space through driver API's.
But that's where my internal stack blows out.
- dexwiz 5y agoYou’re hitting a wall moving from mathematical theory to hardware implementation. I hit a similar wall at some point. When writing a rendering pipeline the problem is not the math, but making real world devices do that math.
- ninepoints 5y agoIt sounds like you’re quite nearly there actually! One important skill imo is the ability to treat a certain layer of the stack or process like a black box (inputs and outputs). A fully generalized scene pipeline is layer upon layer of boxes, many of which will be opaque when you start off. How are clouds rendered? Fog? Reflections? Shadows? Ambient light? Each of these areas is an active research topic and you definitely couldn’t hope to understand all of it all at once.
- Jasper_ 5y ago> I don't get how the matrix operations somehow magically work out. There's two secrets to this. The first trick is remembering what matrices do to vectors, boils down to equations of this form: x' = M[0] * x + M[1] * y + M[2] * z y' = M[3] * x + M[4] * y + M[5] * z z' = M[6] * x + M[7] * y + M[8] * z I won't write the function for matrix/matrix multiplication, but when we invented it, we chose a function that's associative with respect to matrix/vector multiplication. That means that Ma * (Mb * v) = (Ma * Mb) * v. This turns out to be a very good property, because we can then "collapse" every single linear transform we ever want into a single matrix. Stack these however high you want: (Ma * Mb * Mc * Md * Me * Mf * ...) will always collapse down to a constant number of numbers. In computer graphics, we tend to have a few "standard" matrices converting up the chain of spaces like this: vProjectiveSpacePosition = mProjectiveFromView * mViewFromWorld * mWorldFromModel * mModelFromBone * vBoneSpacePosition And you can add your own if you want! The second thing is that we cheat when it comes to perspective. The "correct" way to think about it is that your 4x4 matrix transforms into a 4-dimensional space known as "projective space" where parallel lines meet at some point. But that's confusing, the better way to think about it is that we can't elegantly represent perspective with just 3 coordinates, so we cheat and add a weird fourth one. Don't worry about it too much, the math is mostly handled by higher-level libraries. Once you need to figure things out yourself, you should be able to learn what you need to learn. But for now, just get comfortable with the above. > I don't get how it is that light bouncing/reflectivity works itself out in any reapectable amount of time We actually don't do "light bouncing" in real-time, we typically emulate it. Think of it like this: if you shoot a bunch of light rays at a thing in the real world and measure the light back, you'll come back with a bunch of light reflected back (towards a sensor, but it could also be towards your eye). Now try to curve fit that data to some equation. That's one of the most popular models for object materials, "Trowbridge-Reitz": https://www.desmos.com/calculator/8otf8w37ke https://www.desmos.com/calculator/8otf8w37ke . In practice, it's a combination of curve fitting to real-world data and a lot of smart people thinking about how to make it make physical sense. This models parameterized to work on some known set of materials (the working theory is "microfacets", which are tiny grooves on an object assumed to be mirrors). There are other models you can have, too, but this is the workhorse of the games industry. To get reflections, we play tricks: pre-compute the incoming light for a given reflection vector, so it doesn't have to be done at runtime. But this comment is already long enough. Contact info is in profile if you want to ask me more questions.
- gfodor 5y agoAll you see at a pixel is an estimation of the reflected light from all the light sources from the surfaces that provide a potential light path from the camera to the source (bounced accordingly off intermediate surfaces.) In practice, it’s just a ton of hacks to estimate this value. It turns out if you do this reasonably accurately across all pixels and surfaces you get a pretty picture. Anything else is just optimization. Read PBRT to learn how basic irradiance estimation should work and then rasterization becomes less about understanding the goal and more about understanding the hacks needed to achieve the goal in real time.