mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 01:37:53 -06:00
Tech ENABLE_LEGACY_OPENGL_REMOVAL - Fixed calculation of normal matrices sent to shaders
(cherry picked from commit prusa3d/PrusaSlicer@c468dcbed7)
This commit is contained in:
parent
4fb5b1f904
commit
19ad0ca4d9
29 changed files with 175 additions and 152 deletions
|
@ -410,7 +410,7 @@ void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3
|
|||
shader->set_uniform("object_max_z", m_object_max_z);
|
||||
shader->set_uniform("view_model_matrix", Transform3d::Identity());
|
||||
shader->set_uniform("projection_matrix", Transform3d::Identity());
|
||||
shader->set_uniform("normal_matrix", (Matrix3d)Eigen::Matrix3d::Identity());
|
||||
shader->set_uniform("view_normal_matrix", (Matrix3d)Matrix3d::Identity());
|
||||
|
||||
glsafe(::glPixelStorei(GL_UNPACK_ALIGNMENT, 1));
|
||||
glsafe(::glBindTexture(GL_TEXTURE_2D, m_z_texture_id));
|
||||
|
@ -569,9 +569,11 @@ void GLCanvas3D::LayersEditing::render_volumes(const GLCanvas3D& canvas, const G
|
|||
|
||||
shader->set_uniform("volume_world_matrix", glvolume->world_matrix());
|
||||
shader->set_uniform("object_max_z", 0.0f);
|
||||
const Transform3d view_model_matrix = camera.get_view_matrix() * glvolume->world_matrix();
|
||||
shader->set_uniform("view_model_matrix", view_model_matrix);
|
||||
shader->set_uniform("normal_matrix", (Matrix3d)view_model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
|
||||
const Transform3d& view_matrix = camera.get_view_matrix();
|
||||
const Transform3d model_matrix = glvolume->world_matrix();
|
||||
shader->set_uniform("view_model_matrix", view_matrix * model_matrix);
|
||||
const Matrix3d view_normal_matrix = view_matrix.matrix().block(0, 0, 3, 3) * model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose();
|
||||
shader->set_uniform("view_normal_matrix", view_normal_matrix);
|
||||
|
||||
glvolume->render();
|
||||
}
|
||||
|
@ -5597,10 +5599,11 @@ void GLCanvas3D::render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
|||
|
||||
const bool is_active = vol->is_active;
|
||||
vol->is_active = true;
|
||||
const Transform3d matrix = view_matrix * vol->world_matrix();
|
||||
shader->set_uniform("view_model_matrix", matrix);
|
||||
const Transform3d model_matrix = vol->world_matrix();
|
||||
shader->set_uniform("view_model_matrix", view_matrix * model_matrix);
|
||||
shader->set_uniform("projection_matrix", projection_matrix);
|
||||
shader->set_uniform("normal_matrix", (Matrix3d) matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
|
||||
const Matrix3d view_normal_matrix = view_matrix.matrix().block(0, 0, 3, 3) * model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose();
|
||||
shader->set_uniform("view_normal_matrix", view_normal_matrix);
|
||||
vol->simple_render(shader, model_objects, extruder_colors);
|
||||
vol->is_active = is_active;
|
||||
}
|
||||
|
@ -5634,10 +5637,11 @@ void GLCanvas3D::render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
|||
// the volume may have been deactivated by an active gizmo
|
||||
const bool is_active = vol->is_active;
|
||||
vol->is_active = true;
|
||||
const Transform3d matrix = view_matrix * vol->world_matrix();
|
||||
shader->set_uniform("view_model_matrix", matrix);
|
||||
const Transform3d model_matrix = vol->world_matrix();
|
||||
shader->set_uniform("view_model_matrix", view_matrix * model_matrix);
|
||||
shader->set_uniform("projection_matrix", projection_matrix);
|
||||
shader->set_uniform("normal_matrix", (Matrix3d) matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
|
||||
const Matrix3d view_normal_matrix = view_matrix.matrix().block(0, 0, 3, 3) * model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose();
|
||||
shader->set_uniform("view_normal_matrix", view_normal_matrix);
|
||||
vol->simple_render(shader, model_objects, extruder_colors);
|
||||
vol->is_active = is_active;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue