RendererBackend::begin();
- add_shader_data(standard_shdata);
commands.begin_frame(frame_index);
}
void Renderer::set_camera(const Camera &c)
{
get_state().camera = &c;
- add_shader_data(c.get_shader_data());
set_matrix(Matrix());
}
bool shprog_changed = (state.shprog!=ps.get_shader_program());
ps.set_shader_program(state.shprog);
+ bool shdata_changed = changed&SHADER_DATA;
+ for(auto i=shdata_stack.begin(); (!shdata_changed && i!=shdata_stack.end()); ++i)
+ shdata_changed = (i->shdata->get_generation()!=i->generation);
+ bool extra_shdata = (shdata_stack.size()>state.shdata_count);
+
+ if(changed&CAMERA)
+ {
+ shdata_changed = true;
+ changed &= ~CAMERA;
+ }
+
if(changed&MATRIX)
{
standard_shdata.uniform("world_obj_matrix", state.model_matrix);
nm = transpose(invert(nm));
standard_shdata.uniform("world_obj_normal_matrix", nm);
changed &= ~MATRIX;
+ shdata_changed = true;
}
- bool shdata_changed = changed&SHADER_DATA;
- for(auto i=shdata_stack.begin(); (!shdata_changed && i!=shdata_stack.end()); ++i)
- shdata_changed = (i->shdata->get_generation()!=i->generation);
- bool extra_shdata = (shdata_stack.size()>state.shdata_count);
-
if(shdata_changed || shprog_changed || pipeline_changed || extra_shdata)
{
if(extra_shdata)
shdata_stack.erase(shdata_stack.begin()+state.shdata_count, shdata_stack.end());
+ standard_shdata.apply(*state.shprog, ps, frame_index);
+ if(state.camera)
+ state.camera->get_shader_data().apply(*state.shprog, ps, frame_index);
for(const BoundProgramData &d: shdata_stack)
{
d.shdata->apply(*state.shprog, ps, frame_index);