In my program, my light sources are defined by:
vec3 direction (unit directional vector. ie. 0,0,1 for looking down the Z axis away from the screen)
My third-person camera is defined by:
vec3 view (location of what it is looking at)
vec3 distance (distance from the view)
vec3 orbit (rotation around the view in radians)
vec3 up (the ‘up’ vector)
These values for the camera become a mat4 (perspective matrix) and are passed to the vertex shader as a uniform.
The camera and the lights work fine.
As you can see my camera’s facing is defined initially by its orbit and up vectors and ultimately by the resulting mat4 perspective matrix.
My question is, how can I mathematically obtain a unit directional vector from either; the mat4, or the orbit vector.
The reason I want to do this is that I have a light that I want to face the same direction as the camera.