Tech ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES - Use vertex attributes and matrices in shaders.
Shader: gouraud_light - Thumbnails render
This commit is contained in:
parent
3003db411f
commit
14f4345389
@ -270,6 +270,17 @@ Point Bed3D::point_projection(const Point& point) const
|
|||||||
return m_polygon.point_projection(point);
|
return m_polygon.point_projection(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
void Bed3D::render(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, float scale_factor, bool show_axes, bool show_texture)
|
||||||
|
{
|
||||||
|
render_internal(canvas, view_matrix, projection_matrix, bottom, scale_factor, show_axes, show_texture, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Bed3D::render_for_picking(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, float scale_factor)
|
||||||
|
{
|
||||||
|
render_internal(canvas, view_matrix, projection_matrix, bottom, scale_factor, false, false, true);
|
||||||
|
}
|
||||||
|
#else
|
||||||
void Bed3D::render(GLCanvas3D& canvas, bool bottom, float scale_factor, bool show_axes, bool show_texture)
|
void Bed3D::render(GLCanvas3D& canvas, bool bottom, float scale_factor, bool show_axes, bool show_texture)
|
||||||
{
|
{
|
||||||
render_internal(canvas, bottom, scale_factor, show_axes, show_texture, false);
|
render_internal(canvas, bottom, scale_factor, show_axes, show_texture, false);
|
||||||
@ -279,9 +290,15 @@ void Bed3D::render_for_picking(GLCanvas3D& canvas, bool bottom, float scale_fact
|
|||||||
{
|
{
|
||||||
render_internal(canvas, bottom, scale_factor, false, false, true);
|
render_internal(canvas, bottom, scale_factor, false, false, true);
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
void Bed3D::render_internal(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, float scale_factor,
|
||||||
|
bool show_axes, bool show_texture, bool picking)
|
||||||
|
#else
|
||||||
void Bed3D::render_internal(GLCanvas3D& canvas, bool bottom, float scale_factor,
|
void Bed3D::render_internal(GLCanvas3D& canvas, bool bottom, float scale_factor,
|
||||||
bool show_axes, bool show_texture, bool picking)
|
bool show_axes, bool show_texture, bool picking)
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
{
|
{
|
||||||
m_scale_factor = scale_factor;
|
m_scale_factor = scale_factor;
|
||||||
|
|
||||||
@ -298,9 +315,15 @@ void Bed3D::render_internal(GLCanvas3D& canvas, bool bottom, float scale_factor,
|
|||||||
|
|
||||||
switch (m_type)
|
switch (m_type)
|
||||||
{
|
{
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
case Type::System: { render_system(canvas, view_matrix, projection_matrix, bottom, show_texture); break; }
|
||||||
|
default:
|
||||||
|
case Type::Custom: { render_custom(canvas, view_matrix, projection_matrix, bottom, show_texture, picking); break; }
|
||||||
|
#else
|
||||||
case Type::System: { render_system(canvas, bottom, show_texture); break; }
|
case Type::System: { render_system(canvas, bottom, show_texture); break; }
|
||||||
default:
|
default:
|
||||||
case Type::Custom: { render_custom(canvas, bottom, show_texture, picking); break; }
|
case Type::Custom: { render_custom(canvas, bottom, show_texture, picking); break; }
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
}
|
}
|
||||||
|
|
||||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||||
@ -492,6 +515,16 @@ void Bed3D::render_axes()
|
|||||||
m_axes.render();
|
m_axes.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
void Bed3D::render_system(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_texture)
|
||||||
|
{
|
||||||
|
if (!bottom)
|
||||||
|
render_model(view_matrix, projection_matrix);
|
||||||
|
|
||||||
|
if (show_texture)
|
||||||
|
render_texture(bottom, canvas);
|
||||||
|
}
|
||||||
|
#else
|
||||||
void Bed3D::render_system(GLCanvas3D& canvas, bool bottom, bool show_texture)
|
void Bed3D::render_system(GLCanvas3D& canvas, bool bottom, bool show_texture)
|
||||||
{
|
{
|
||||||
if (!bottom)
|
if (!bottom)
|
||||||
@ -500,6 +533,7 @@ void Bed3D::render_system(GLCanvas3D& canvas, bool bottom, bool show_texture)
|
|||||||
if (show_texture)
|
if (show_texture)
|
||||||
render_texture(bottom, canvas);
|
render_texture(bottom, canvas);
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
|
||||||
void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas)
|
void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas)
|
||||||
{
|
{
|
||||||
@ -661,7 +695,11 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas)
|
|||||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
void Bed3D::render_model(const Transform3d& view_matrix, const Transform3d& projection_matrix)
|
||||||
|
#else
|
||||||
void Bed3D::render_model()
|
void Bed3D::render_model()
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
{
|
{
|
||||||
if (m_model_filename.empty())
|
if (m_model_filename.empty())
|
||||||
return;
|
return;
|
||||||
@ -690,10 +728,9 @@ void Bed3D::render_model()
|
|||||||
shader->start_using();
|
shader->start_using();
|
||||||
shader->set_uniform("emission_factor", 0.0f);
|
shader->set_uniform("emission_factor", 0.0f);
|
||||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
const Transform3d matrix = view_matrix * Geometry::assemble_transform(m_model_offset);
|
||||||
const Transform3d matrix = camera.get_view_matrix() * Geometry::assemble_transform(m_model_offset);
|
|
||||||
shader->set_uniform("view_model_matrix", matrix);
|
shader->set_uniform("view_model_matrix", matrix);
|
||||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
shader->set_uniform("projection_matrix", projection_matrix);
|
||||||
shader->set_uniform("normal_matrix", (Matrix3d)matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
|
shader->set_uniform("normal_matrix", (Matrix3d)matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
|
||||||
#else
|
#else
|
||||||
glsafe(::glPushMatrix());
|
glsafe(::glPushMatrix());
|
||||||
@ -708,7 +745,11 @@ void Bed3D::render_model()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
void Bed3D::render_custom(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_texture, bool picking)
|
||||||
|
#else
|
||||||
void Bed3D::render_custom(GLCanvas3D& canvas, bool bottom, bool show_texture, bool picking)
|
void Bed3D::render_custom(GLCanvas3D& canvas, bool bottom, bool show_texture, bool picking)
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
{
|
{
|
||||||
if (m_texture_filename.empty() && m_model_filename.empty()) {
|
if (m_texture_filename.empty() && m_model_filename.empty()) {
|
||||||
render_default(bottom, picking);
|
render_default(bottom, picking);
|
||||||
@ -716,7 +757,11 @@ void Bed3D::render_custom(GLCanvas3D& canvas, bool bottom, bool show_texture, bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!bottom)
|
if (!bottom)
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
render_model(view_matrix, projection_matrix);
|
||||||
|
#else
|
||||||
render_model();
|
render_model();
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
|
||||||
if (show_texture)
|
if (show_texture)
|
||||||
render_texture(bottom, canvas);
|
render_texture(bottom, canvas);
|
||||||
|
@ -139,8 +139,13 @@ public:
|
|||||||
bool contains(const Point& point) const;
|
bool contains(const Point& point) const;
|
||||||
Point point_projection(const Point& point) const;
|
Point point_projection(const Point& point) const;
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
void render(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, float scale_factor, bool show_axes, bool show_texture);
|
||||||
|
void render_for_picking(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, float scale_factor);
|
||||||
|
#else
|
||||||
void render(GLCanvas3D& canvas, bool bottom, float scale_factor, bool show_axes, bool show_texture);
|
void render(GLCanvas3D& canvas, bool bottom, float scale_factor, bool show_axes, bool show_texture);
|
||||||
void render_for_picking(GLCanvas3D& canvas, bool bottom, float scale_factor);
|
void render_for_picking(GLCanvas3D& canvas, bool bottom, float scale_factor);
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Calculate an extended bounding box from axes and current model for visualization purposes.
|
// Calculate an extended bounding box from axes and current model for visualization purposes.
|
||||||
@ -153,13 +158,27 @@ private:
|
|||||||
void calc_gridlines(const ExPolygon& poly, const BoundingBox& bed_bbox);
|
void calc_gridlines(const ExPolygon& poly, const BoundingBox& bed_bbox);
|
||||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
static std::tuple<Type, std::string, std::string> detect_type(const Pointfs& shape);
|
static std::tuple<Type, std::string, std::string> detect_type(const Pointfs& shape);
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
void render_internal(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, float scale_factor,
|
||||||
|
bool show_axes, bool show_texture, bool picking);
|
||||||
|
#else
|
||||||
void render_internal(GLCanvas3D& canvas, bool bottom, float scale_factor,
|
void render_internal(GLCanvas3D& canvas, bool bottom, float scale_factor,
|
||||||
bool show_axes, bool show_texture, bool picking);
|
bool show_axes, bool show_texture, bool picking);
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
void render_axes();
|
void render_axes();
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
void render_system(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_texture);
|
||||||
|
#else
|
||||||
void render_system(GLCanvas3D& canvas, bool bottom, bool show_texture);
|
void render_system(GLCanvas3D& canvas, bool bottom, bool show_texture);
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
void render_texture(bool bottom, GLCanvas3D& canvas);
|
void render_texture(bool bottom, GLCanvas3D& canvas);
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
void render_model(const Transform3d& view_matrix, const Transform3d& projection_matrix);
|
||||||
|
void render_custom(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_texture, bool picking);
|
||||||
|
#else
|
||||||
void render_model();
|
void render_model();
|
||||||
void render_custom(GLCanvas3D& canvas, bool bottom, bool show_texture, bool picking);
|
void render_custom(GLCanvas3D& canvas, bool bottom, bool show_texture, bool picking);
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
void render_default(bool bottom, bool picking);
|
void render_default(bool bottom, bool picking);
|
||||||
#if !ENABLE_GLBEGIN_GLEND_REMOVAL
|
#if !ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
void release_VBOs();
|
void release_VBOs();
|
||||||
|
@ -714,14 +714,7 @@ void GLVolume::render()
|
|||||||
glsafe(::glCullFace(GL_BACK));
|
glsafe(::glCullFace(GL_BACK));
|
||||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
bool use_attributes = boost::algorithm::iends_with(shader->get_name(), "_attr");
|
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
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
glsafe(::glPushMatrix());
|
glsafe(::glPushMatrix());
|
||||||
glsafe(::glMultMatrixd(world_matrix().data()));
|
glsafe(::glMultMatrixd(world_matrix().data()));
|
||||||
@ -1083,7 +1076,12 @@ GLVolumeWithIdAndZList volumes_to_render(const GLVolumePtrs& volumes, GLVolumeCo
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disable_cullface, const Transform3d& view_matrix, const Transform3d& projection_matrix,
|
||||||
|
std::function<bool(const GLVolume&)> filter_func) const
|
||||||
|
#else
|
||||||
void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disable_cullface, const Transform3d& view_matrix, std::function<bool(const GLVolume&)> filter_func) const
|
void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disable_cullface, const Transform3d& view_matrix, std::function<bool(const GLVolume&)> filter_func) const
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
{
|
{
|
||||||
GLVolumeWithIdAndZList to_render = volumes_to_render(volumes, type, view_matrix, filter_func);
|
GLVolumeWithIdAndZList to_render = volumes_to_render(volumes, type, view_matrix, filter_func);
|
||||||
if (to_render.empty())
|
if (to_render.empty())
|
||||||
@ -1097,6 +1095,7 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
|
|||||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
GLShaderProgram* sink_shader = GUI::wxGetApp().get_shader("flat_attr");
|
GLShaderProgram* sink_shader = GUI::wxGetApp().get_shader("flat_attr");
|
||||||
GLShaderProgram* edges_shader = GUI::wxGetApp().get_shader("flat_attr");
|
GLShaderProgram* edges_shader = GUI::wxGetApp().get_shader("flat_attr");
|
||||||
|
bool use_attributes = boost::algorithm::iends_with(shader->get_name(), "_attr");
|
||||||
#else
|
#else
|
||||||
GLShaderProgram* sink_shader = GUI::wxGetApp().get_shader("flat");
|
GLShaderProgram* sink_shader = GUI::wxGetApp().get_shader("flat");
|
||||||
GLShaderProgram* edges_shader = GUI::wxGetApp().get_shader("flat");
|
GLShaderProgram* edges_shader = GUI::wxGetApp().get_shader("flat");
|
||||||
@ -1139,8 +1138,14 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
|
|||||||
shader->start_using();
|
shader->start_using();
|
||||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
if (!use_attributes) {
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
glsafe(::glEnableClientState(GL_VERTEX_ARRAY));
|
glsafe(::glEnableClientState(GL_VERTEX_ARRAY));
|
||||||
glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
|
glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
}
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
|
||||||
#if ENABLE_GLINDEXEDVERTEXARRAY_REMOVAL
|
#if ENABLE_GLINDEXEDVERTEXARRAY_REMOVAL
|
||||||
if (!volume.first->model.is_initialized())
|
if (!volume.first->model.is_initialized())
|
||||||
@ -1168,6 +1173,14 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
|
|||||||
#if ENABLE_GLINDEXEDVERTEXARRAY_REMOVAL
|
#if ENABLE_GLINDEXEDVERTEXARRAY_REMOVAL
|
||||||
volume.first->model.set_color(volume.first->render_color);
|
volume.first->model.set_color(volume.first->render_color);
|
||||||
#endif // ENABLE_GLINDEXEDVERTEXARRAY_REMOVAL
|
#endif // ENABLE_GLINDEXEDVERTEXARRAY_REMOVAL
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
if (use_attributes) {
|
||||||
|
const Transform3d matrix = view_matrix * volume.first->world_matrix();
|
||||||
|
shader->set_uniform("view_model_matrix", matrix);
|
||||||
|
shader->set_uniform("projection_matrix", projection_matrix);
|
||||||
|
shader->set_uniform("normal_matrix", (Matrix3d)matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
|
||||||
|
}
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
volume.first->render();
|
volume.first->render();
|
||||||
|
|
||||||
#if ENABLE_ENVIRONMENT_MAP
|
#if ENABLE_ENVIRONMENT_MAP
|
||||||
@ -1178,8 +1191,14 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
|
|||||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
|
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
|
||||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
|
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
if (!use_attributes) {
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
glsafe(::glDisableClientState(GL_VERTEX_ARRAY));
|
glsafe(::glDisableClientState(GL_VERTEX_ARRAY));
|
||||||
glsafe(::glDisableClientState(GL_NORMAL_ARRAY));
|
glsafe(::glDisableClientState(GL_NORMAL_ARRAY));
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
}
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_show_sinking_contours) {
|
if (m_show_sinking_contours) {
|
||||||
|
@ -687,7 +687,12 @@ public:
|
|||||||
#endif // ENABLE_GLINDEXEDVERTEXARRAY_REMOVAL
|
#endif // ENABLE_GLINDEXEDVERTEXARRAY_REMOVAL
|
||||||
|
|
||||||
// Render the volumes by OpenGL.
|
// Render the volumes by OpenGL.
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
void render(ERenderType type, bool disable_cullface, const Transform3d& view_matrix, const Transform3d& projection_matrix,
|
||||||
|
std::function<bool(const GLVolume&)> filter_func = std::function<bool(const GLVolume&)>()) const;
|
||||||
|
#else
|
||||||
void render(ERenderType type, bool disable_cullface, const Transform3d& view_matrix, std::function<bool(const GLVolume&)> filter_func = std::function<bool(const GLVolume&)>()) const;
|
void render(ERenderType type, bool disable_cullface, const Transform3d& view_matrix, std::function<bool(const GLVolume&)> filter_func = std::function<bool(const GLVolume&)>()) const;
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
|
||||||
#if !ENABLE_GLINDEXEDVERTEXARRAY_REMOVAL
|
#if !ENABLE_GLINDEXEDVERTEXARRAY_REMOVAL
|
||||||
// Finalize the initialization of the geometry & indices,
|
// Finalize the initialization of the geometry & indices,
|
||||||
|
@ -3256,7 +3256,12 @@ void GCodeViewer::render_shells()
|
|||||||
// glsafe(::glDepthMask(GL_FALSE));
|
// glsafe(::glDepthMask(GL_FALSE));
|
||||||
|
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
|
m_shells.volumes.render(GLVolumeCollection::ERenderType::Transparent, true, camera.get_view_matrix(), camera.get_projection_matrix());
|
||||||
|
#else
|
||||||
m_shells.volumes.render(GLVolumeCollection::ERenderType::Transparent, true, wxGetApp().plater()->get_camera().get_view_matrix());
|
m_shells.volumes.render(GLVolumeCollection::ERenderType::Transparent, true, wxGetApp().plater()->get_camera().get_view_matrix());
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
shader->stop_using();
|
shader->stop_using();
|
||||||
|
|
||||||
// glsafe(::glDepthMask(GL_TRUE));
|
// glsafe(::glDepthMask(GL_TRUE));
|
||||||
|
@ -1645,7 +1645,11 @@ void GLCanvas3D::render()
|
|||||||
_render_gcode();
|
_render_gcode();
|
||||||
_render_sla_slices();
|
_render_sla_slices();
|
||||||
_render_selection();
|
_render_selection();
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
_render_bed(camera.get_view_matrix(), camera.get_projection_matrix(), !camera.is_looking_downward(), true);
|
||||||
|
#else
|
||||||
_render_bed(!camera.is_looking_downward(), true);
|
_render_bed(!camera.is_looking_downward(), true);
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
_render_objects(GLVolumeCollection::ERenderType::Transparent);
|
_render_objects(GLVolumeCollection::ERenderType::Transparent);
|
||||||
|
|
||||||
_render_sequential_clearance();
|
_render_sequential_clearance();
|
||||||
@ -4413,6 +4417,10 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
|||||||
camera.zoom_to_box(volumes_box);
|
camera.zoom_to_box(volumes_box);
|
||||||
camera.apply_view_matrix();
|
camera.apply_view_matrix();
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
const Transform3d& view_matrix = camera.get_view_matrix();
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
|
||||||
double near_z = -1.0;
|
double near_z = -1.0;
|
||||||
double far_z = -1.0;
|
double far_z = -1.0;
|
||||||
|
|
||||||
@ -4420,14 +4428,22 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
|||||||
// extends the near and far z of the frustrum to avoid the bed being clipped
|
// extends the near and far z of the frustrum to avoid the bed being clipped
|
||||||
|
|
||||||
// box in eye space
|
// box in eye space
|
||||||
BoundingBoxf3 t_bed_box = m_bed.extended_bounding_box().transformed(camera.get_view_matrix());
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
const BoundingBoxf3 t_bed_box = m_bed.extended_bounding_box().transformed(view_matrix);
|
||||||
|
#else
|
||||||
|
const BoundingBoxf3 t_bed_box = m_bed.extended_bounding_box().transformed(camera.get_view_matrix());
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
near_z = -t_bed_box.max.z();
|
near_z = -t_bed_box.max.z();
|
||||||
far_z = -t_bed_box.min.z();
|
far_z = -t_bed_box.min.z();
|
||||||
}
|
}
|
||||||
|
|
||||||
camera.apply_projection(volumes_box, near_z, far_z);
|
camera.apply_projection(volumes_box, near_z, far_z);
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light_attr");
|
||||||
|
#else
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
if (shader == nullptr)
|
if (shader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -4440,6 +4456,10 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
|||||||
shader->start_using();
|
shader->start_using();
|
||||||
shader->set_uniform("emission_factor", 0.0f);
|
shader->set_uniform("emission_factor", 0.0f);
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
const Transform3d& projection_matrix = camera.get_projection_matrix();
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
|
||||||
for (GLVolume* vol : visible_volumes) {
|
for (GLVolume* vol : visible_volumes) {
|
||||||
#if ENABLE_GLINDEXEDVERTEXARRAY_REMOVAL
|
#if ENABLE_GLINDEXEDVERTEXARRAY_REMOVAL
|
||||||
vol->model.set_color((vol->printable && !vol->is_outside) ? (current_printer_technology() == ptSLA ? vol->color : ColorRGBA::ORANGE()) : ColorRGBA::GRAY());
|
vol->model.set_color((vol->printable && !vol->is_outside) ? (current_printer_technology() == ptSLA ? vol->color : ColorRGBA::ORANGE()) : ColorRGBA::GRAY());
|
||||||
@ -4447,8 +4467,14 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
|||||||
shader->set_uniform("uniform_color", (vol->printable && !vol->is_outside) ? (current_printer_technology() == ptSLA ? vol->color : ColorRGBA::ORANGE()) : ColorRGBA::GRAY());
|
shader->set_uniform("uniform_color", (vol->printable && !vol->is_outside) ? (current_printer_technology() == ptSLA ? vol->color : ColorRGBA::ORANGE()) : ColorRGBA::GRAY());
|
||||||
#endif // ENABLE_GLINDEXEDVERTEXARRAY_REMOVAL
|
#endif // ENABLE_GLINDEXEDVERTEXARRAY_REMOVAL
|
||||||
// the volume may have been deactivated by an active gizmo
|
// the volume may have been deactivated by an active gizmo
|
||||||
bool is_active = vol->is_active;
|
const bool is_active = vol->is_active;
|
||||||
vol->is_active = true;
|
vol->is_active = true;
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
const Transform3d matrix = view_matrix * vol->world_matrix();
|
||||||
|
shader->set_uniform("view_model_matrix", matrix);
|
||||||
|
shader->set_uniform("projection_matrix", projection_matrix);
|
||||||
|
shader->set_uniform("normal_matrix", (Matrix3d)matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
vol->render();
|
vol->render();
|
||||||
vol->is_active = is_active;
|
vol->is_active = is_active;
|
||||||
}
|
}
|
||||||
@ -4458,7 +4484,11 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
|||||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||||
|
|
||||||
if (thumbnail_params.show_bed)
|
if (thumbnail_params.show_bed)
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
_render_bed(view_matrix, projection_matrix, !camera.is_looking_downward(), false);
|
||||||
|
#else
|
||||||
_render_bed(!camera.is_looking_downward(), false);
|
_render_bed(!camera.is_looking_downward(), false);
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
|
||||||
// restore background color
|
// restore background color
|
||||||
if (thumbnail_params.transparent_background)
|
if (thumbnail_params.transparent_background)
|
||||||
@ -5180,7 +5210,12 @@ void GLCanvas3D::_picking_pass()
|
|||||||
if (m_camera_clipping_plane.is_active())
|
if (m_camera_clipping_plane.is_active())
|
||||||
::glDisable(GL_CLIP_PLANE0);
|
::glDisable(GL_CLIP_PLANE0);
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
|
_render_bed_for_picking(camera.get_view_matrix(), camera.get_projection_matrix(), !camera.is_looking_downward());
|
||||||
|
#else
|
||||||
_render_bed_for_picking(!wxGetApp().plater()->get_camera().is_looking_downward());
|
_render_bed_for_picking(!wxGetApp().plater()->get_camera().is_looking_downward());
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
|
||||||
m_gizmos.render_current_gizmo_for_picking_pass();
|
m_gizmos.render_current_gizmo_for_picking_pass();
|
||||||
|
|
||||||
@ -5236,7 +5271,12 @@ void GLCanvas3D::_rectangular_selection_picking_pass()
|
|||||||
glsafe(::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
|
glsafe(::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
|
||||||
|
|
||||||
_render_volumes_for_picking();
|
_render_volumes_for_picking();
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
|
_render_bed_for_picking(camera.get_view_matrix(), camera.get_projection_matrix(), !camera.is_looking_downward());
|
||||||
|
#else
|
||||||
_render_bed_for_picking(!wxGetApp().plater()->get_camera().is_looking_downward());
|
_render_bed_for_picking(!wxGetApp().plater()->get_camera().is_looking_downward());
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
|
||||||
if (m_multisample_allowed)
|
if (m_multisample_allowed)
|
||||||
glsafe(::glEnable(GL_MULTISAMPLE));
|
glsafe(::glEnable(GL_MULTISAMPLE));
|
||||||
@ -5370,7 +5410,11 @@ void GLCanvas3D::_render_background()
|
|||||||
glsafe(::glPopMatrix());
|
glsafe(::glPopMatrix());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
void GLCanvas3D::_render_bed(const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_axes)
|
||||||
|
#else
|
||||||
void GLCanvas3D::_render_bed(bool bottom, bool show_axes)
|
void GLCanvas3D::_render_bed(bool bottom, bool show_axes)
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
{
|
{
|
||||||
float scale_factor = 1.0;
|
float scale_factor = 1.0;
|
||||||
#if ENABLE_RETINA_GL
|
#if ENABLE_RETINA_GL
|
||||||
@ -5384,17 +5428,29 @@ void GLCanvas3D::_render_bed(bool bottom, bool show_axes)
|
|||||||
&& m_gizmos.get_current_type() != GLGizmosManager::Seam
|
&& m_gizmos.get_current_type() != GLGizmosManager::Seam
|
||||||
&& m_gizmos.get_current_type() != GLGizmosManager::MmuSegmentation);
|
&& m_gizmos.get_current_type() != GLGizmosManager::MmuSegmentation);
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
m_bed.render(*this, view_matrix, projection_matrix, bottom, scale_factor, show_axes, show_texture);
|
||||||
|
#else
|
||||||
m_bed.render(*this, bottom, scale_factor, show_axes, show_texture);
|
m_bed.render(*this, bottom, scale_factor, show_axes, show_texture);
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
void GLCanvas3D::_render_bed_for_picking(const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom)
|
||||||
|
#else
|
||||||
void GLCanvas3D::_render_bed_for_picking(bool bottom)
|
void GLCanvas3D::_render_bed_for_picking(bool bottom)
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
{
|
{
|
||||||
float scale_factor = 1.0;
|
float scale_factor = 1.0;
|
||||||
#if ENABLE_RETINA_GL
|
#if ENABLE_RETINA_GL
|
||||||
scale_factor = m_retina_helper->get_scale_factor();
|
scale_factor = m_retina_helper->get_scale_factor();
|
||||||
#endif // ENABLE_RETINA_GL
|
#endif // ENABLE_RETINA_GL
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
m_bed.render_for_picking(*this, view_matrix, projection_matrix, bottom, scale_factor);
|
||||||
|
#else
|
||||||
m_bed.render_for_picking(*this, bottom, scale_factor);
|
m_bed.render_for_picking(*this, bottom, scale_factor);
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type)
|
void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type)
|
||||||
@ -5462,18 +5518,33 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type)
|
|||||||
{
|
{
|
||||||
if (m_picking_enabled && !m_gizmos.is_dragging() && m_layers_editing.is_enabled() && (m_layers_editing.last_object_id != -1) && (m_layers_editing.object_max_z() > 0.0f)) {
|
if (m_picking_enabled && !m_gizmos.is_dragging() && m_layers_editing.is_enabled() && (m_layers_editing.last_object_id != -1) && (m_layers_editing.object_max_z() > 0.0f)) {
|
||||||
int object_id = m_layers_editing.last_object_id;
|
int object_id = m_layers_editing.last_object_id;
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
|
m_volumes.render(type, false, camera.get_view_matrix(), camera.get_projection_matrix(), [object_id](const GLVolume& volume) {
|
||||||
|
// Which volume to paint without the layer height profile shader?
|
||||||
|
return volume.is_active && (volume.is_modifier || volume.composite_id.object_id != object_id);
|
||||||
|
});
|
||||||
|
#else
|
||||||
m_volumes.render(type, false, wxGetApp().plater()->get_camera().get_view_matrix(), [object_id](const GLVolume& volume) {
|
m_volumes.render(type, false, wxGetApp().plater()->get_camera().get_view_matrix(), [object_id](const GLVolume& volume) {
|
||||||
// Which volume to paint without the layer height profile shader?
|
// Which volume to paint without the layer height profile shader?
|
||||||
return volume.is_active && (volume.is_modifier || volume.composite_id.object_id != object_id);
|
return volume.is_active && (volume.is_modifier || volume.composite_id.object_id != object_id);
|
||||||
});
|
});
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
// Let LayersEditing handle rendering of the active object using the layer height profile shader.
|
// Let LayersEditing handle rendering of the active object using the layer height profile shader.
|
||||||
m_layers_editing.render_volumes(*this, m_volumes);
|
m_layers_editing.render_volumes(*this, m_volumes);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// do not cull backfaces to show broken geometry, if any
|
// do not cull backfaces to show broken geometry, if any
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
|
m_volumes.render(type, m_picking_enabled, camera.get_view_matrix(), camera.get_projection_matrix(), [this](const GLVolume& volume) {
|
||||||
|
return (m_render_sla_auxiliaries || volume.composite_id.volume_id >= 0);
|
||||||
|
});
|
||||||
|
#else
|
||||||
m_volumes.render(type, m_picking_enabled, wxGetApp().plater()->get_camera().get_view_matrix(), [this](const GLVolume& volume) {
|
m_volumes.render(type, m_picking_enabled, wxGetApp().plater()->get_camera().get_view_matrix(), [this](const GLVolume& volume) {
|
||||||
return (m_render_sla_auxiliaries || volume.composite_id.volume_id >= 0);
|
return (m_render_sla_auxiliaries || volume.composite_id.volume_id >= 0);
|
||||||
});
|
});
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
}
|
}
|
||||||
|
|
||||||
// In case a painting gizmo is open, it should render the painted triangles
|
// In case a painting gizmo is open, it should render the painted triangles
|
||||||
@ -5492,7 +5563,12 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type)
|
|||||||
}
|
}
|
||||||
case GLVolumeCollection::ERenderType::Transparent:
|
case GLVolumeCollection::ERenderType::Transparent:
|
||||||
{
|
{
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
|
m_volumes.render(type, false, camera.get_view_matrix(), camera.get_projection_matrix());
|
||||||
|
#else
|
||||||
m_volumes.render(type, false, wxGetApp().plater()->get_camera().get_view_matrix());
|
m_volumes.render(type, false, wxGetApp().plater()->get_camera().get_view_matrix());
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -944,8 +944,13 @@ private:
|
|||||||
void _picking_pass();
|
void _picking_pass();
|
||||||
void _rectangular_selection_picking_pass();
|
void _rectangular_selection_picking_pass();
|
||||||
void _render_background();
|
void _render_background();
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
void _render_bed(const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_axes);
|
||||||
|
void _render_bed_for_picking(const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom);
|
||||||
|
#else
|
||||||
void _render_bed(bool bottom, bool show_axes);
|
void _render_bed(bool bottom, bool show_axes);
|
||||||
void _render_bed_for_picking(bool bottom);
|
void _render_bed_for_picking(bool bottom);
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
void _render_objects(GLVolumeCollection::ERenderType type);
|
void _render_objects(GLVolumeCollection::ERenderType type);
|
||||||
void _render_gcode();
|
void _render_gcode();
|
||||||
#if ENABLE_SHOW_TOOLPATHS_COG
|
#if ENABLE_SHOW_TOOLPATHS_COG
|
||||||
|
Loading…
Reference in New Issue
Block a user