world matrix in shader is set for each object

This commit is contained in:
Mikulas Florek 2014-08-19 22:41:20 +02:00
parent 2299572e9d
commit 30be77957b

View file

@ -624,15 +624,14 @@ struct PipelineInstanceImpl : public PipelineInstance
{ {
glPushMatrix(); glPushMatrix();
Matrix world_matrix = m_renderable_infos[i].m_model ? m_renderable_infos[i].m_model->getMatrix() : *m_renderable_infos[i].m_matrix; Matrix world_matrix = m_renderable_infos[i].m_model ? m_renderable_infos[i].m_model->getMatrix() : *m_renderable_infos[i].m_matrix;
world_matrix.multiply3x3(m_renderable_infos[i].m_scale); //world_matrix.multiply3x3(m_renderable_infos[i].m_scale);
glMultMatrixf(&world_matrix.m11); //glMultMatrixf(&world_matrix.m11);
Mesh& mesh = *m_renderable_infos[i].m_mesh; Mesh& mesh = *m_renderable_infos[i].m_mesh;
Material& material = *mesh.getMaterial(); Material& material = *mesh.getMaterial();
if (last_material != &material) if (last_material != &material)
{ {
material.apply(*m_renderer, *this); material.apply(*m_renderer, *this);
material.getShader()->setUniform("world_matrix", world_matrix);
material.getShader()->setUniform("shadowmap_matrix0", m_shadow_modelviewprojection[0]); material.getShader()->setUniform("shadowmap_matrix0", m_shadow_modelviewprojection[0]);
material.getShader()->setUniform("shadowmap_matrix1", m_shadow_modelviewprojection[1]); material.getShader()->setUniform("shadowmap_matrix1", m_shadow_modelviewprojection[1]);
material.getShader()->setUniform("shadowmap_matrix2", m_shadow_modelviewprojection[2]); material.getShader()->setUniform("shadowmap_matrix2", m_shadow_modelviewprojection[2]);
@ -640,6 +639,7 @@ struct PipelineInstanceImpl : public PipelineInstance
material.getShader()->setUniform("light_dir", m_light_dir); material.getShader()->setUniform("light_dir", m_light_dir);
last_material = &material; last_material = &material;
} }
material.getShader()->setUniform("world_matrix", world_matrix);
static Matrix bone_mtx[64]; static Matrix bone_mtx[64];
if (m_renderable_infos[i].m_pose) if (m_renderable_infos[i].m_pose)
{ {