From: Mikko Rasa Date: Wed, 19 Jun 2019 22:55:27 +0000 (+0300) Subject: Expose world-to-eye matrix in Renderer's standard shdata X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=463746f62d9b48f9fbbba3b2fcf7354067873e94;p=libs%2Fgl.git Expose world-to-eye matrix in Renderer's standard shdata --- diff --git a/shaderlib/msp_interface.glsl b/shaderlib/msp_interface.glsl index e606edf9..fda84de9 100644 --- a/shaderlib/msp_interface.glsl +++ b/shaderlib/msp_interface.glsl @@ -22,6 +22,7 @@ uniform mat4 eye_obj_matrix; uniform mat3 eye_obj_normal_matrix; uniform Transform { + mat4 eye_world_matrix; mat4 projection_matrix; }; diff --git a/source/renderer.cpp b/source/renderer.cpp index c213f0a9..e59949a3 100644 --- a/source/renderer.cpp +++ b/source/renderer.cpp @@ -35,7 +35,10 @@ Renderer::Renderer(const Camera *c): if(c) set_camera(*c); else + { standard_shdata.uniform("projection_matrix", Matrix()); + standard_shdata.uniform("eye_world_matrix", Matrix()); + } } Renderer::~Renderer() @@ -54,6 +57,7 @@ void Renderer::set_camera(const Camera &c) { state->camera = &c; standard_shdata.uniform("projection_matrix", state->camera->get_projection_matrix()); + standard_shdata.uniform("eye_world_matrix", state->camera->get_view_matrix()); changed |= STANDARD_SHDATA|LEGACY_PROJECTION; set_matrix(state->camera->get_view_matrix()); } @@ -179,9 +183,15 @@ void Renderer::pop_state() if(camera_changed) { if(state->camera) + { standard_shdata.uniform("projection_matrix", state->camera->get_projection_matrix()); + standard_shdata.uniform("eye_world_matrix", state->camera->get_view_matrix()); + } else + { standard_shdata.uniform("projection_matrix", Matrix()); + standard_shdata.uniform("eye_world_matrix", Matrix()); + } changed |= STANDARD_SHDATA|LEGACY_PROJECTION; } /* This actually should compare the relevant matrices rather than check for