Tech ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES - Use vertex attributes and matrices in shaders.

Shader: gouraud_light - GCodeViewer shells
This commit is contained in:
enricoturri1966 2022-03-03 09:56:13 +01:00
parent 8d43a854c6
commit 3003db411f
2 changed files with 12 additions and 1 deletions

View File

@ -714,7 +714,14 @@ void GLVolume::render()
glsafe(::glCullFace(GL_BACK));
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
bool use_attributes = boost::algorithm::iends_with(shader->get_name(), "_attr");
if (!use_attributes) {
if (use_attributes) {
const GUI::Camera& camera = GUI::wxGetApp().plater()->get_camera();
const Transform3d matrix = camera.get_view_matrix() * world_matrix();
shader->set_uniform("view_model_matrix", matrix);
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
shader->set_uniform("normal_matrix", (Matrix3d)matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
}
else {
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
glsafe(::glPushMatrix());
glsafe(::glMultMatrixd(world_matrix().data()));

View File

@ -3235,7 +3235,11 @@ void GCodeViewer::render_shells()
if (!m_shells.visible || m_shells.volumes.empty())
return;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light_attr");
#else
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
if (shader == nullptr)
return;