From 685de3108868fa017d48b038b89cd2da19478fd0 Mon Sep 17 00:00:00 2001 From: SoftFever Date: Tue, 5 Dec 2023 22:05:11 +0800 Subject: [PATCH] Revert "Add a simple subtle outline effect by drawing back faces using wireframe mode (#2934)" This reverts commit 0cee51341688996c278b1fa1fbe2af99b66e4fe9. --- resources/shaders/110/gouraud.fs | 10 +--------- resources/shaders/140/gouraud.fs | 10 +--------- src/slic3r/GUI/3DScene.cpp | 29 ++++------------------------- src/slic3r/GUI/GCodeViewer.cpp | 5 ++--- 4 files changed, 8 insertions(+), 46 deletions(-) diff --git a/resources/shaders/110/gouraud.fs b/resources/shaders/110/gouraud.fs index 7c90ee25d5..6f354ff9a6 100644 --- a/resources/shaders/110/gouraud.fs +++ b/resources/shaders/110/gouraud.fs @@ -54,11 +54,6 @@ varying vec4 world_pos; varying float world_normal_z; varying vec3 eye_normal; -vec3 getBackfaceColor(vec3 fill) { - float brightness = 0.2126 * fill.r + 0.7152 * fill.g + 0.0722 * fill.b; - return (brightness > 0.75) ? vec3(0.11, 0.165, 0.208) : vec3(0.988, 0.988, 0.988); -} - void main() { if (any(lessThan(clipping_planes_dots, ZERO))) @@ -100,11 +95,8 @@ void main() } color.rgb = (any(lessThan(pv_check_min, ZERO)) || any(greaterThan(pv_check_max, ZERO))) ? mix(color.rgb, ZERO, 0.3333) : color.rgb; - // Orca: add backface outline - if (!gl_FrontFacing) - gl_FragColor = vec4(getBackfaceColor(color.rgb), 1.0); //BBS: add outline_color - else if (is_outline) + if (is_outline) gl_FragColor = uniform_color; #ifdef ENABLE_ENVIRONMENT_MAP else if (use_environment_tex) diff --git a/resources/shaders/140/gouraud.fs b/resources/shaders/140/gouraud.fs index ece05fc985..84bce5c035 100644 --- a/resources/shaders/140/gouraud.fs +++ b/resources/shaders/140/gouraud.fs @@ -56,11 +56,6 @@ in vec3 eye_normal; out vec4 out_color; -vec3 getBackfaceColor(vec3 fill) { - float brightness = 0.2126 * fill.r + 0.7152 * fill.g + 0.0722 * fill.b; - return (brightness > 0.75) ? vec3(0.11, 0.165, 0.208) : vec3(0.988, 0.988, 0.988); -} - void main() { if (any(lessThan(clipping_planes_dots, ZERO))) @@ -102,11 +97,8 @@ void main() } color.rgb = (any(lessThan(pv_check_min, ZERO)) || any(greaterThan(pv_check_max, ZERO))) ? mix(color.rgb, ZERO, 0.3333) : color.rgb; - // Orca: add backface outline - if (!gl_FrontFacing) - out_color = vec4(getBackfaceColor(color.rgb), 1.0); //BBS: add outline_color - else if (is_outline) + if (is_outline) out_color = uniform_color; #ifdef ENABLE_ENVIRONMENT_MAP else if (use_environment_tex) diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index 0d00c8ccd9..f407a999a6 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -472,6 +472,10 @@ void GLVolume::render_with_outline(const Transform3d &view_model_matrix) //BBS add render for simple case void GLVolume::simple_render(GLShaderProgram* shader, ModelObjectPtrs& model_objects, std::vector extruder_colors) { + if (this->is_left_handed()) + glFrontFace(GL_CW); + glsafe(::glCullFace(GL_BACK)); + bool color_volume = false; ModelObject* model_object = nullptr; ModelVolume* model_volume = nullptr; @@ -500,7 +504,6 @@ void GLVolume::simple_render(GLShaderProgram* shader, ModelObjectPtrs& model_obj } } while (0); - auto r = [&]() { if (color_volume && !picking) { // when force_transparent, we need to keep the alpha if (force_native_color && render_color.is_transparent()) { @@ -542,29 +545,6 @@ void GLVolume::simple_render(GLShaderProgram* shader, ModelObjectPtrs& model_obj else model.render(this->tverts_range); } - }; - - if (this->is_left_handed()) - glFrontFace(GL_CW); - - // Render front faces - glsafe(::glCullFace(GL_BACK)); - r(); - - // Then render back faces in line mode to add an outline - GLboolean cull_face = GL_FALSE; - ::glGetBooleanv(GL_CULL_FACE, &cull_face); - glsafe(::glEnable(GL_CULL_FACE)); - glsafe(::glCullFace(GL_FRONT)); - glsafe(::glPolygonMode(GL_BACK, GL_LINE)); - r(); - - // Reset mode - glsafe(::glPolygonMode(GL_BACK, GL_FILL)); - glsafe(::glCullFace(GL_BACK)); - if (!cull_face) - glsafe(::glDisable(GL_CULL_FACE)); - if (this->is_left_handed()) glFrontFace(GL_CCW); } @@ -874,7 +854,6 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab } glsafe(::glCullFace(GL_BACK)); - glsafe(::glEnable(GL_CULL_FACE)); if (disable_cullface) glsafe(::glDisable(GL_CULL_FACE)); diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 2ef664c2b2..aedc729bc0 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -1247,7 +1247,6 @@ void GCodeViewer::render(int canvas_width, int canvas_height, int right_margin) glsafe(::glEnable(GL_DEPTH_TEST)); render_shells(); - glsafe(::glClear(GL_DEPTH_BUFFER_BIT)); // This makes sure toolpaths are on top of shells render_toolpaths(); float legend_height = 0.0f; render_legend(legend_height, canvas_width, canvas_height, right_margin); @@ -4031,7 +4030,7 @@ void GCodeViewer::render_shells() if (shader == nullptr) return; - //glsafe(::glDepthMask(GL_FALSE)); + glsafe(::glDepthMask(GL_FALSE)); shader->start_using(); shader->set_uniform("emission_factor", 0.1f); @@ -4040,7 +4039,7 @@ void GCodeViewer::render_shells() shader->set_uniform("emission_factor", 0.0f); shader->stop_using(); - //glsafe(::glDepthMask(GL_TRUE)); + glsafe(::glDepthMask(GL_TRUE)); } //BBS