mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-06 05:24:01 -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
|
@ -54,6 +54,11 @@ 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)))
|
||||
|
@ -95,8 +100,11 @@ 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
|
||||
if (is_outline)
|
||||
else if (is_outline)
|
||||
gl_FragColor = uniform_color;
|
||||
#ifdef ENABLE_ENVIRONMENT_MAP
|
||||
else if (use_environment_tex)
|
||||
|
|
|
@ -56,6 +56,11 @@ 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)))
|
||||
|
@ -97,8 +102,11 @@ 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
|
||||
if (is_outline)
|
||||
else if (is_outline)
|
||||
out_color = uniform_color;
|
||||
#ifdef ENABLE_ENVIRONMENT_MAP
|
||||
else if (use_environment_tex)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue