void main()
{
gl_Position = vec4(vertex.xy, 1.0, 1.0);
- mat4 inv_projection = inverse(clip_eye_matrix);
- out vec4 view_dir = inv_projection*vec4(vertex.xy, -1.0, 1.0);
+ out vec4 view_dir = eye_clip_matrix*vec4(vertex.xy, -1.0, 1.0);
view_dir /= view_dir.w;
- view_dir = inverse(eye_world_matrix)*vec4(view_dir.xyz, 0.0);
+ view_dir = world_eye_matrix*vec4(view_dir.xyz, 0.0);
}
#pragma MSP stage(fragment)
uniform mat4 world_obj_matrix;
uniform mat3 world_obj_normal_matrix;
-uniform Transform
+uniform CameraTransform
{
mat4 eye_world_matrix;
+ mat4 world_eye_matrix;
mat4 clip_eye_matrix;
+ mat4 eye_clip_matrix;
};
uniform Lighting
proj_matrix = Matrix::rotation(rotate, Vector3(0, 0, 1))*proj_matrix;
shdata.uniform("clip_eye_matrix", proj_matrix);
+ shdata.uniform("eye_clip_matrix", invert(proj_matrix));
}
void Camera::update_object_matrix()
matrix = Matrix::from_columns(columns);
view_matrix = invert(matrix);
+ shdata.uniform("world_eye_matrix", matrix);
shdata.uniform("eye_world_matrix", view_matrix);
}