mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 23:06:13 +08:00
Merge branch 'master' into fs_emboss
This commit is contained in:
commit
40817f537b
@ -26,8 +26,6 @@ struct SlopeDetection
|
|||||||
uniform vec4 uniform_color;
|
uniform vec4 uniform_color;
|
||||||
uniform SlopeDetection slope;
|
uniform SlopeDetection slope;
|
||||||
|
|
||||||
uniform bool offset_depth_buffer;
|
|
||||||
|
|
||||||
#ifdef ENABLE_ENVIRONMENT_MAP
|
#ifdef ENABLE_ENVIRONMENT_MAP
|
||||||
uniform sampler2D environment_tex;
|
uniform sampler2D environment_tex;
|
||||||
uniform bool use_environment_tex;
|
uniform bool use_environment_tex;
|
||||||
@ -78,9 +76,4 @@ void main()
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
gl_FragColor = vec4(vec3(intensity.y) + color * intensity.x, alpha);
|
gl_FragColor = vec4(vec3(intensity.y) + color * intensity.x, alpha);
|
||||||
|
|
||||||
// In the support painting gizmo and the seam painting gizmo are painted triangles rendered over the already
|
|
||||||
// rendered object. To resolved z-fighting between previously rendered object and painted triangles, values
|
|
||||||
// inside the depth buffer are offset by small epsilon for painted triangles inside those gizmos.
|
|
||||||
gl_FragDepth = gl_FragCoord.z - (offset_depth_buffer ? EPSILON : 0.0);
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,8 @@
|
|||||||
#version 110
|
#version 110
|
||||||
|
|
||||||
const float EPSILON = 0.0001;
|
|
||||||
|
|
||||||
uniform vec4 uniform_color;
|
uniform vec4 uniform_color;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_FragColor = uniform_color;
|
gl_FragColor = uniform_color;
|
||||||
// Values inside depth buffer for fragments of the contour of a selected area are offset
|
|
||||||
// by small epsilon to solve z-fighting between painted triangles and contour lines.
|
|
||||||
gl_FragDepth = gl_FragCoord.z - EPSILON;
|
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,14 @@
|
|||||||
|
|
||||||
uniform mat4 view_model_matrix;
|
uniform mat4 view_model_matrix;
|
||||||
uniform mat4 projection_matrix;
|
uniform mat4 projection_matrix;
|
||||||
|
uniform float offset;
|
||||||
|
|
||||||
attribute vec3 v_position;
|
attribute vec3 v_position;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
// Add small epsilon to z to solve z-fighting between painted triangles and contour lines.
|
||||||
|
vec4 clip_position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
||||||
|
clip_position.z -= offset * abs(clip_position.w);
|
||||||
|
gl_Position = clip_position;
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,6 @@ struct SlopeDetection
|
|||||||
uniform vec4 uniform_color;
|
uniform vec4 uniform_color;
|
||||||
uniform SlopeDetection slope;
|
uniform SlopeDetection slope;
|
||||||
|
|
||||||
uniform bool offset_depth_buffer;
|
|
||||||
|
|
||||||
#ifdef ENABLE_ENVIRONMENT_MAP
|
#ifdef ENABLE_ENVIRONMENT_MAP
|
||||||
uniform sampler2D environment_tex;
|
uniform sampler2D environment_tex;
|
||||||
uniform bool use_environment_tex;
|
uniform bool use_environment_tex;
|
||||||
@ -78,9 +76,4 @@ void main()
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
gl_FragColor = vec4(vec3(intensity.y) + color * intensity.x, alpha);
|
gl_FragColor = vec4(vec3(intensity.y) + color * intensity.x, alpha);
|
||||||
|
|
||||||
// In the support painting gizmo and the seam painting gizmo are painted triangles rendered over the already
|
|
||||||
// rendered object. To resolved z-fighting between previously rendered object and painted triangles, values
|
|
||||||
// inside the depth buffer are offset by small epsilon for painted triangles inside those gizmos.
|
|
||||||
gl_FragDepth = gl_FragCoord.z - (offset_depth_buffer ? EPSILON : 0.0);
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,8 @@
|
|||||||
#version 140
|
#version 140
|
||||||
|
|
||||||
const float EPSILON = 0.0001;
|
|
||||||
|
|
||||||
uniform vec4 uniform_color;
|
uniform vec4 uniform_color;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_FragColor = uniform_color;
|
gl_FragColor = uniform_color;
|
||||||
// Values inside depth buffer for fragments of the contour of a selected area are offset
|
|
||||||
// by small epsilon to solve z-fighting between painted triangles and contour lines.
|
|
||||||
gl_FragDepth = gl_FragCoord.z - EPSILON;
|
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,14 @@
|
|||||||
|
|
||||||
uniform mat4 view_model_matrix;
|
uniform mat4 view_model_matrix;
|
||||||
uniform mat4 projection_matrix;
|
uniform mat4 projection_matrix;
|
||||||
|
uniform float offset;
|
||||||
|
|
||||||
in vec3 v_position;
|
in vec3 v_position;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
// Add small epsilon to z to solve z-fighting between painted triangles and contour lines.
|
||||||
|
vec4 clip_position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
||||||
|
clip_position.z -= offset * abs(clip_position.w);
|
||||||
|
gl_Position = clip_position;
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,6 @@ struct SlopeDetection
|
|||||||
uniform vec4 uniform_color;
|
uniform vec4 uniform_color;
|
||||||
uniform SlopeDetection slope;
|
uniform SlopeDetection slope;
|
||||||
|
|
||||||
uniform bool offset_depth_buffer;
|
|
||||||
|
|
||||||
#ifdef ENABLE_ENVIRONMENT_MAP
|
#ifdef ENABLE_ENVIRONMENT_MAP
|
||||||
uniform sampler2D environment_tex;
|
uniform sampler2D environment_tex;
|
||||||
uniform bool use_environment_tex;
|
uniform bool use_environment_tex;
|
||||||
@ -78,9 +76,4 @@ void main()
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
gl_FragColor = vec4(vec3(intensity.y) + color * intensity.x, alpha);
|
gl_FragColor = vec4(vec3(intensity.y) + color * intensity.x, alpha);
|
||||||
|
|
||||||
// In the support painting gizmo and the seam painting gizmo are painted triangles rendered over the already
|
|
||||||
// rendered object. To resolved z-fighting between previously rendered object and painted triangles, values
|
|
||||||
// inside the depth buffer are offset by small epsilon for painted triangles inside those gizmos.
|
|
||||||
gl_FragDepth = gl_FragCoord.z - (offset_depth_buffer ? EPSILON : 0.0);
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
#version 110
|
#version 110
|
||||||
|
|
||||||
const float EPSILON = 0.0001;
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
|
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
|
||||||
// Values inside depth buffer for fragments of the contour of a selected area are offset
|
|
||||||
// by small epsilon to solve z-fighting between painted triangles and contour lines.
|
|
||||||
gl_FragDepth = gl_FragCoord.z - EPSILON;
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
#version 110
|
#version 110
|
||||||
|
|
||||||
|
uniform float offset;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = ftransform();
|
// Add small epsilon to z to solve z-fighting between painted triangles and contour lines.
|
||||||
|
vec4 clip_position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||||
|
clip_position.z -= offset * abs(clip_position.w);
|
||||||
|
gl_Position = clip_position;
|
||||||
}
|
}
|
||||||
|
@ -5351,7 +5351,7 @@ void GLCanvas3D::_picking_pass()
|
|||||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
m_camera_clipping_plane = m_gizmos.get_clipping_plane();
|
m_camera_clipping_plane = m_gizmos.get_clipping_plane();
|
||||||
if (m_camera_clipping_plane.is_active()) {
|
if (m_camera_clipping_plane.is_active()) {
|
||||||
::glClipPlane(GL_CLIP_PLANE0, (GLdouble*)m_camera_clipping_plane.get_data());
|
::glClipPlane(GL_CLIP_PLANE0, (GLdouble*)m_camera_clipping_plane.get_data().data());
|
||||||
::glEnable(GL_CLIP_PLANE0);
|
::glEnable(GL_CLIP_PLANE0);
|
||||||
}
|
}
|
||||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "slic3r/GUI/format.hpp"
|
#include "slic3r/GUI/format.hpp"
|
||||||
#include "slic3r/GUI/GUI_ObjectList.hpp"
|
#include "slic3r/GUI/GUI_ObjectList.hpp"
|
||||||
#include "slic3r/GUI/NotificationManager.hpp"
|
#include "slic3r/GUI/NotificationManager.hpp"
|
||||||
|
#include "slic3r/GUI/OpenGLManager.hpp"
|
||||||
#include "libslic3r/PresetBundle.hpp"
|
#include "libslic3r/PresetBundle.hpp"
|
||||||
#include "libslic3r/Model.hpp"
|
#include "libslic3r/Model.hpp"
|
||||||
#include "slic3r/Utils/UndoRedo.hpp"
|
#include "slic3r/Utils/UndoRedo.hpp"
|
||||||
@ -627,11 +628,8 @@ void TriangleSelectorMmGui::render(ImGuiWrapper *imgui)
|
|||||||
|
|
||||||
auto *contour_shader = wxGetApp().get_shader("mm_contour");
|
auto *contour_shader = wxGetApp().get_shader("mm_contour");
|
||||||
contour_shader->start_using();
|
contour_shader->start_using();
|
||||||
|
contour_shader->set_uniform("offset", OpenGLManager::get_gl_info().is_mesa() ? 0.0005 : 0.00001);
|
||||||
glsafe(::glDepthFunc(GL_LEQUAL));
|
|
||||||
m_paint_contour.render();
|
m_paint_contour.render();
|
||||||
glsafe(::glDepthFunc(GL_LESS));
|
|
||||||
|
|
||||||
contour_shader->stop_using();
|
contour_shader->stop_using();
|
||||||
}
|
}
|
||||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "slic3r/GUI/GUI_App.hpp"
|
#include "slic3r/GUI/GUI_App.hpp"
|
||||||
#include "slic3r/GUI/Camera.hpp"
|
#include "slic3r/GUI/Camera.hpp"
|
||||||
#include "slic3r/GUI/Plater.hpp"
|
#include "slic3r/GUI/Plater.hpp"
|
||||||
|
#include "slic3r/GUI/OpenGLManager.hpp"
|
||||||
#include "slic3r/Utils/UndoRedo.hpp"
|
#include "slic3r/Utils/UndoRedo.hpp"
|
||||||
#include "libslic3r/Model.hpp"
|
#include "libslic3r/Model.hpp"
|
||||||
#include "libslic3r/PresetBundle.hpp"
|
#include "libslic3r/PresetBundle.hpp"
|
||||||
@ -284,9 +285,11 @@ void GLGizmoPainterBase::render_cursor_sphere(const Transform3d& trafo) const
|
|||||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
if (shader == nullptr)
|
if (shader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
|
|
||||||
const Transform3d complete_scaling_matrix_inverse = Geometry::Transformation(trafo).get_matrix(true, true, false, true).inverse();
|
const Transform3d complete_scaling_matrix_inverse = Geometry::Transformation(trafo).get_matrix(true, true, false, true).inverse();
|
||||||
const bool is_left_handed = Geometry::Transformation(trafo).is_left_handed();
|
const bool is_left_handed = Geometry::Transformation(trafo).is_left_handed();
|
||||||
@ -918,8 +921,6 @@ void TriangleSelectorGUI::render(ImGuiWrapper* imgui)
|
|||||||
|
|
||||||
assert(shader->get_name() == "gouraud");
|
assert(shader->get_name() == "gouraud");
|
||||||
|
|
||||||
ScopeGuard guard([shader]() { if (shader) shader->set_uniform("offset_depth_buffer", false);});
|
|
||||||
shader->set_uniform("offset_depth_buffer", true);
|
|
||||||
for (auto iva : {std::make_pair(&m_iva_enforcers, enforcers_color),
|
for (auto iva : {std::make_pair(&m_iva_enforcers, enforcers_color),
|
||||||
std::make_pair(&m_iva_blockers, blockers_color)}) {
|
std::make_pair(&m_iva_blockers, blockers_color)}) {
|
||||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
@ -967,11 +968,8 @@ void TriangleSelectorGUI::render(ImGuiWrapper* imgui)
|
|||||||
|
|
||||||
auto *contour_shader = wxGetApp().get_shader("mm_contour");
|
auto *contour_shader = wxGetApp().get_shader("mm_contour");
|
||||||
contour_shader->start_using();
|
contour_shader->start_using();
|
||||||
|
contour_shader->set_uniform("offset", OpenGLManager::get_gl_info().is_mesa() ? 0.0005 : 0.00001);
|
||||||
glsafe(::glDepthFunc(GL_LEQUAL));
|
|
||||||
m_paint_contour.render();
|
m_paint_contour.render();
|
||||||
glsafe(::glDepthFunc(GL_LESS));
|
|
||||||
|
|
||||||
contour_shader->stop_using();
|
contour_shader->stop_using();
|
||||||
}
|
}
|
||||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
@ -1014,6 +1012,9 @@ void TriangleSelectorGUI::update_render_data()
|
|||||||
iva.release_geometry();
|
iva.release_geometry();
|
||||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
|
|
||||||
|
// small value used to offset triangles along their normal to avoid z-fighting
|
||||||
|
static const float offset = 0.001f;
|
||||||
|
|
||||||
for (const Triangle &tr : m_triangles) {
|
for (const Triangle &tr : m_triangles) {
|
||||||
if (!tr.valid() || tr.is_split() || (tr.get_state() == EnforcerBlockerType::NONE && !tr.is_selected_by_seed_fill()))
|
if (!tr.valid() || tr.is_split() || (tr.get_state() == EnforcerBlockerType::NONE && !tr.is_selected_by_seed_fill()))
|
||||||
continue;
|
continue;
|
||||||
@ -1037,15 +1038,17 @@ void TriangleSelectorGUI::update_render_data()
|
|||||||
//FIXME the normal may likely be pulled from m_triangle_selectors, but it may not be worth the effort
|
//FIXME the normal may likely be pulled from m_triangle_selectors, but it may not be worth the effort
|
||||||
// or the current implementation may be more cache friendly.
|
// or the current implementation may be more cache friendly.
|
||||||
const Vec3f n = (v1 - v0).cross(v2 - v1).normalized();
|
const Vec3f n = (v1 - v0).cross(v2 - v1).normalized();
|
||||||
|
// small value used to offset triangles along their normal to avoid z-fighting
|
||||||
|
const Vec3f offset_n = offset * n;
|
||||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
iva.add_vertex(v0, n);
|
iva.add_vertex(v0 + offset_n, n);
|
||||||
iva.add_vertex(v1, n);
|
iva.add_vertex(v1 + offset_n, n);
|
||||||
iva.add_vertex(v2, n);
|
iva.add_vertex(v2 + offset_n, n);
|
||||||
iva.add_triangle((unsigned int)cnt, (unsigned int)cnt + 1, (unsigned int)cnt + 2);
|
iva.add_triangle((unsigned int)cnt, (unsigned int)cnt + 1, (unsigned int)cnt + 2);
|
||||||
#else
|
#else
|
||||||
iva.push_geometry(v0, n);
|
iva.push_geometry(v0 + offset_n, n);
|
||||||
iva.push_geometry(v1, n);
|
iva.push_geometry(v1 + offset_n, n);
|
||||||
iva.push_geometry(v2, n);
|
iva.push_geometry(v2 + offset_n, n);
|
||||||
iva.push_triangle(cnt, cnt + 1, cnt + 2);
|
iva.push_triangle(cnt, cnt + 1, cnt + 2);
|
||||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
cnt += 3;
|
cnt += 3;
|
||||||
@ -1361,16 +1364,14 @@ void TriangleSelectorGUI::render_paint_contour()
|
|||||||
if (contour_shader != nullptr) {
|
if (contour_shader != nullptr) {
|
||||||
contour_shader->start_using();
|
contour_shader->start_using();
|
||||||
|
|
||||||
|
contour_shader->set_uniform("offset", OpenGLManager::get_gl_info().is_mesa() ? 0.0005 : 0.00001);
|
||||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
contour_shader->set_uniform("view_model_matrix", camera.get_view_matrix() * matrix);
|
contour_shader->set_uniform("view_model_matrix", camera.get_view_matrix() * matrix);
|
||||||
contour_shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
contour_shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
|
|
||||||
glsafe(::glDepthFunc(GL_LEQUAL));
|
|
||||||
m_paint_contour.render();
|
m_paint_contour.render();
|
||||||
glsafe(::glDepthFunc(GL_LESS));
|
|
||||||
|
|
||||||
contour_shader->stop_using();
|
contour_shader->stop_using();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "slic3r/GUI/NotificationManager.hpp"
|
#include "slic3r/GUI/NotificationManager.hpp"
|
||||||
#include "slic3r/GUI/Plater.hpp"
|
#include "slic3r/GUI/Plater.hpp"
|
||||||
#include "slic3r/GUI/format.hpp"
|
#include "slic3r/GUI/format.hpp"
|
||||||
|
#include "slic3r/GUI/OpenGLManager.hpp"
|
||||||
#include "libslic3r/AppConfig.hpp"
|
#include "libslic3r/AppConfig.hpp"
|
||||||
#include "libslic3r/Model.hpp"
|
#include "libslic3r/Model.hpp"
|
||||||
#include "libslic3r/QuadricEdgeCollapse.hpp"
|
#include "libslic3r/QuadricEdgeCollapse.hpp"
|
||||||
@ -756,6 +757,7 @@ void GLGizmoSimplify::on_render()
|
|||||||
if (m_show_wireframe) {
|
if (m_show_wireframe) {
|
||||||
auto *contour_shader = wxGetApp().get_shader("mm_contour");
|
auto *contour_shader = wxGetApp().get_shader("mm_contour");
|
||||||
contour_shader->start_using();
|
contour_shader->start_using();
|
||||||
|
contour_shader->set_uniform("offset", OpenGLManager::get_gl_info().is_mesa() ? 0.0005 : 0.00001);
|
||||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
contour_shader->set_uniform("view_model_matrix", view_model_matrix);
|
contour_shader->set_uniform("view_model_matrix", view_model_matrix);
|
||||||
contour_shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
contour_shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||||
|
@ -65,6 +65,11 @@ const std::string& OpenGLManager::GLInfo::get_renderer() const
|
|||||||
return m_renderer;
|
return m_renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OpenGLManager::GLInfo::is_mesa() const
|
||||||
|
{
|
||||||
|
return boost::icontains(m_version, "mesa");
|
||||||
|
}
|
||||||
|
|
||||||
int OpenGLManager::GLInfo::get_max_tex_size() const
|
int OpenGLManager::GLInfo::get_max_tex_size() const
|
||||||
{
|
{
|
||||||
if (!m_detected)
|
if (!m_detected)
|
||||||
|
@ -40,6 +40,8 @@ public:
|
|||||||
const std::string& get_vendor() const;
|
const std::string& get_vendor() const;
|
||||||
const std::string& get_renderer() const;
|
const std::string& get_renderer() const;
|
||||||
|
|
||||||
|
bool is_mesa() const;
|
||||||
|
|
||||||
int get_max_tex_size() const;
|
int get_max_tex_size() const;
|
||||||
float get_max_anisotropy() const;
|
float get_max_anisotropy() const;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user