Changing Coordinate Systems.
You're modeling in an abstract 3D scene. It's a virtual abstract mathematical scene, that you need to get onto the screen.
Object Space
All objects start in objects space, centered around the DCC (digital content creation) origin.
What is it good for? Most of the time the OS matrix is just Identity. What about object/joint presets?
What if you wanted to change the pivot point? You have to create a new object space transformation, usually:
OS = T * Rz * Ry * Rx * S * I
It's a matrix that moves the object in object space to be relative to the origin where you want it to be.
Sometimes called the Pretransformation (applying a transform right onto the object before you do anything else) Often used to change the pivot point.
This is the last place anyone is going to look for a transformation, so its best you don't mess with this too much.
World Space
All objects in a scene are collected into World Space, (AKA Scene Space). Every object inside of your scene has been manipulated into world space.
A World Transformation Matrix transforms each model in Object Space into a single common World Space
Rule of thumb: Use Post-Multiply transform order, "Reverse Order".
EX: WS = T * Rz * Ry * Rx * S
You can see the world transformation matrix on any geo node in Houdini using worldTransform() function.
Here there's no data on the object, the world transform is still the identity matrix |
Now you can see the world transform has been changed after I scaled up Rubberto and moved him around in the scene |
Here you can see the rotation matrix is also shown in the world transform matrix. |
If you take the inverse of the world transformation, you can put it back to the world position without any transformation data on it. What's the use of it? Well if you're a vfx artist and want to transforma vfx, you want to do it at the origin, or else the scale is going to throw it off. So you want to transform it back to the origin, perform your operations, and then send it back
View/Camera Space
Establish which direction is "Up" and which objects are visible in camera. View Matrix Transforms objects to view Space. What really happens is that it remaps the world space so that the camera is at the origin and looks down along the minus-Z axis. This makes the math easier when the camera is moving and rotating in the scene. Now instead of the camera moving, everything else moves around it.
How to create CS MatrixProper Way: CS = inverted(Camera's world space matrix), then multiply everything in the scene against that.
Hacky Way: (Assuming S > R > T), reverse the order of the negative rotations and translations.
CS = -CRx * -CRy * -CRz * CT(-x, -y, -z)
Matrix Rendering Transformations
Projection Space: we need to transform all objects into the 2D Display. All objects needs to be flattened into a 2D plane.
Near and Far clipping planes, Field of View and Aspect Ratios need to be take into consideration.
The Projection Space is what will be projected into a 2D plane. It is a frustum, with the smaller top being the near clipping plane and the bigger bottom being the far clipping plane.
Two Types of Projection Space
- Orthographic Projection: Universe is parallel
- This is the Orthographic Matrix
This Matrix works if you've followed the order we've done so far, Post Multiplication of the World Transform, and then multiplied against a point. |
- This produces a flattened model. Although to our eyes looking through the camara it looks the same
- Perspective Projection: Universe has perspective
There are technically 4 different versions, DirectX has Left handed vs Right handed space and Open GL also has Left handed vs Right handed space (so 4 in total)
After the point is multiplied against perspective Matrix, it is still not flat. The Perspective Projection swapped z and w in order to translate to correct z position. Divide each component by w to flatten. The GPU does this for you already.
So if done correctly, your z value should end up as 1, and you only have the x and y values left since it's 2D now.
No comments:
Post a Comment