From: Mikko Rasa Date: Mon, 5 Dec 2016 17:50:48 +0000 (+0200) Subject: Refresh lighting and culling uniforms if the camera changes in pop_state X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=6a045019fbd68738b77849629e6dfd3dfd9a4d93;p=libs%2Fgl.git Refresh lighting and culling uniforms if the camera changes in pop_state --- diff --git a/source/renderer.cpp b/source/renderer.cpp index e57967d9..c8972934 100644 --- a/source/renderer.cpp +++ b/source/renderer.cpp @@ -166,12 +166,16 @@ void Renderer::pop_state() } shdata_applied = min(shdata_applied, shdata_stack.size()); changed |= MATRIX; - if(state->camera!=old_camera) + bool camera_changed = (state->camera!=old_camera); + if(camera_changed) { standard_shdata.uniform("projection_matrix", state->camera->get_projection_matrix()); changed |= STANDARD_SHDATA|LEGACY_PROJECTION; } - if(state->lighting!=old_lighting) + /* This actually should compare the relevant matrices rather than check for + camera, but in practice lighting and clipping is set right after the camera + and a boolean check is much faster than matrix comparison. */ + if(state->lighting!=old_lighting || camera_changed) { if(state->lighting) { @@ -180,7 +184,7 @@ void Renderer::pop_state() } changed |= LEGACY_LIGHTING; } - if(state->clipping!=old_clipping) + if(state->clipping!=old_clipping || camera_changed) { if(state->clipping) {