I have a question regarding the camera matrix. I don't quite understand how that variable actually works, or what value does it hold. Am I right to assume that it's the current camera position in the world position? Thanks!
The CAMERA_MATRIX is a transformation matrix that, when multiplied with some coordinates, converts the coordinates from world space to view space.
In the tutorial, the line:
down_camera_angle = (vec4(0, -1, 0, 1) * CAMERA_MATRIX).xyz;
Projects a vector pointing down onto the view.
Hello! There are multiple coordinate systems in shaders:
The matrices are mathematical constructs that, when multiplied with a Vector, transform a point from one coordinate system to another:
There is one more transformation you don't have access to, which happens between the fragment and vertex shader which turns the vertex into 'NDC', or normalized device coordinates.
The default vertex shader, unless you use special render modes or the POSITION built-in, will multiply the vertex and normal by the modelview matrix, then by the projection matrix.
Oh okay, so those matrices will change a vector from one coordinate space to another, thanks for the answers!