Expose world-to-eye matrix in Renderer's standard shdata
authorMikko Rasa <tdb@tdb.fi>
Wed, 19 Jun 2019 22:55:27 +0000 (01:55 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 19 Jun 2019 23:24:02 +0000 (02:24 +0300)
shaderlib/msp_interface.glsl
source/renderer.cpp

index e606edf94a55e24f4956c2fab0fb5ad15aa9011a..fda84de95fff74de5ec6fc11180a05bc6a872168 100644 (file)
@@ -22,6 +22,7 @@ uniform mat4 eye_obj_matrix;
 uniform mat3 eye_obj_normal_matrix;
 uniform Transform
 {
+       mat4 eye_world_matrix;
        mat4 projection_matrix;
 };
 
index c213f0a987218f579fbc4991fc6722bece0e083a..e59949a3683f938797251a4a5d3f34a7ebbddc46 100644 (file)
@@ -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