mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 01:37:53 -06:00
Add a simple subtle outline effect by drawing back faces using wireframe mode (#2934)
* Add a simple subtle outline effect by drawing back faces using wireframe mode * Show outline in white if the model color is too dark * Make the outline algorithm more reliable * Enable cull face, which fix render on Linux * Fix `disable_cullface`
This commit is contained in:
parent
2745575dd2
commit
0cee513416
4 changed files with 46 additions and 8 deletions
|
@ -472,10 +472,6 @@ 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<ColorRGBA> 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;
|
||||
|
@ -504,6 +500,7 @@ 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()) {
|
||||
|
@ -545,6 +542,29 @@ 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);
|
||||
}
|
||||
|
@ -854,6 +874,7 @@ 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));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue