mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
make xray solid color depending on what it occludes
This commit is contained in:
parent
1b2cc7f7a7
commit
82b2f23689
6 changed files with 25 additions and 11 deletions
|
@ -125,7 +125,8 @@ class SolidView(View):
|
||||||
self._xray_composite_shader = OpenGL.getInstance().createShaderProgram(os.path.join(PluginRegistry.getInstance().getPluginPath("SolidView"), "xray_composite.shader"))
|
self._xray_composite_shader = OpenGL.getInstance().createShaderProgram(os.path.join(PluginRegistry.getInstance().getPluginPath("SolidView"), "xray_composite.shader"))
|
||||||
theme = Application.getInstance().getTheme()
|
theme = Application.getInstance().getTheme()
|
||||||
self._xray_composite_shader.setUniformValue("u_background_color", Color(*theme.getColor("viewport_background").getRgb()))
|
self._xray_composite_shader.setUniformValue("u_background_color", Color(*theme.getColor("viewport_background").getRgb()))
|
||||||
self._xray_composite_shader.setUniformValue("u_error_color", Color(*theme.getColor("xray_error").getRgb()))
|
self._xray_composite_shader.setUniformValue("u_xray_error_dark", Color(*theme.getColor("xray_error_dark").getRgb()))
|
||||||
|
self._xray_composite_shader.setUniformValue("u_xray_error_light", Color(*theme.getColor("xray_error_light").getRgb()))
|
||||||
self._xray_composite_shader.setUniformValue("u_outline_color", Color(*theme.getColor("model_selection_outline").getRgb()))
|
self._xray_composite_shader.setUniformValue("u_outline_color", Color(*theme.getColor("model_selection_outline").getRgb()))
|
||||||
|
|
||||||
if not self.getRenderer().getRenderPass("xray"):
|
if not self.getRenderer().getRenderPass("xray"):
|
||||||
|
|
|
@ -28,7 +28,8 @@ fragment =
|
||||||
|
|
||||||
uniform float u_outline_strength;
|
uniform float u_outline_strength;
|
||||||
uniform vec4 u_outline_color;
|
uniform vec4 u_outline_color;
|
||||||
uniform vec4 u_error_color;
|
uniform vec4 u_xray_error_dark;
|
||||||
|
uniform vec4 u_xray_error_light;
|
||||||
uniform vec4 u_background_color;
|
uniform vec4 u_background_color;
|
||||||
uniform float u_xray_error_strength;
|
uniform float u_xray_error_strength;
|
||||||
|
|
||||||
|
@ -62,13 +63,14 @@ fragment =
|
||||||
if(mod(intersection_count, 2.0) >= 1.0)
|
if(mod(intersection_count, 2.0) >= 1.0)
|
||||||
{
|
{
|
||||||
float lightness = (result.r + result.g + result.b) / 3.0;
|
float lightness = (result.r + result.g + result.b) / 3.0;
|
||||||
if (hash12(v_uvs) < lightness)
|
//if ( (mod((v_uvs.x / u_offset[8].x - v_uvs.y / u_offset[8].y) * 0.1, 2.0) >= 1.0) == (mod((v_uvs.x / u_offset[8].x + v_uvs.y / u_offset[8].y) * 0.1, 2.0) >= 1.0) ) // diamond pattern
|
||||||
|
if (lightness > 0.5)
|
||||||
{
|
{
|
||||||
result = result * (1.0 - u_xray_error_strength) + u_xray_error_strength * u_error_color;
|
result = result * (1.0 - u_xray_error_strength) + u_xray_error_strength * u_xray_error_dark;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result = result * (1.0 - u_xray_error_strength) + u_xray_error_strength * (vec4(1.0) - u_error_color);
|
result = result * (1.0 - u_xray_error_strength) + u_xray_error_strength * u_xray_error_light;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +118,8 @@ fragment41core =
|
||||||
|
|
||||||
uniform float u_outline_strength;
|
uniform float u_outline_strength;
|
||||||
uniform vec4 u_outline_color;
|
uniform vec4 u_outline_color;
|
||||||
uniform vec4 u_error_color;
|
uniform vec4 u_xray_error_dark;
|
||||||
|
uniform vec4 u_xray_error_light;
|
||||||
uniform vec4 u_background_color;
|
uniform vec4 u_background_color;
|
||||||
uniform float u_xray_error_strength;
|
uniform float u_xray_error_strength;
|
||||||
|
|
||||||
|
@ -151,13 +154,14 @@ fragment41core =
|
||||||
if(mod(intersection_count, 2.0) >= 1.0)
|
if(mod(intersection_count, 2.0) >= 1.0)
|
||||||
{
|
{
|
||||||
float lightness = (result.r + result.g + result.b) / 3.0;
|
float lightness = (result.r + result.g + result.b) / 3.0;
|
||||||
if (hash12(v_uvs) < lightness)
|
//if ( (mod((v_uvs.x / u_offset[8].x - v_uvs.y / u_offset[8].y) * 0.1, 2.0) >= 1.0) == (mod((v_uvs.x / u_offset[8].x + v_uvs.y / u_offset[8].y) * 0.1, 2.0) >= 1.0) ) // diamond pattern
|
||||||
|
if (lightness > 0.5)
|
||||||
{
|
{
|
||||||
result = result * (1.0 - u_xray_error_strength) + u_xray_error_strength * u_error_color;
|
result = result * (1.0 - u_xray_error_strength) + u_xray_error_strength * u_xray_error_dark;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result = result * (1.0 - u_xray_error_strength) + u_xray_error_strength * (vec4(1.0) - u_error_color);
|
result = result * (1.0 - u_xray_error_strength) + u_xray_error_strength * u_xray_error_light;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +192,9 @@ u_layer2 = 2
|
||||||
u_background_color = [0.965, 0.965, 0.965, 1.0]
|
u_background_color = [0.965, 0.965, 0.965, 1.0]
|
||||||
u_outline_strength = 1.0
|
u_outline_strength = 1.0
|
||||||
u_outline_color = [0.05, 0.66, 0.89, 1.0]
|
u_outline_color = [0.05, 0.66, 0.89, 1.0]
|
||||||
u_error_color = [1.0, 0.0, 0.0, 1.0]
|
u_error_color = [0.0, 0.0, 0.0, 1.0]
|
||||||
|
u_xray_error_dark = [1.0, 0.0, 0.0, 1.0]
|
||||||
|
u_xray_error_light = [1.0, 1.0, 0.0, 1.0]
|
||||||
u_xray_error_strength = 0.4
|
u_xray_error_strength = 0.4
|
||||||
|
|
||||||
[bindings]
|
[bindings]
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
"model_overhang": [200, 0, 255, 255],
|
"model_overhang": [200, 0, 255, 255],
|
||||||
|
|
||||||
|
|
||||||
|
"xray_error_dark": [255, 0, 0, 255],
|
||||||
|
"xray_error_light": [255, 255, 0, 255],
|
||||||
"xray": [26, 26, 62, 255],
|
"xray": [26, 26, 62, 255],
|
||||||
"xray_error": [255, 0, 0, 255],
|
"xray_error": [255, 0, 0, 255],
|
||||||
|
|
||||||
|
|
|
@ -190,6 +190,8 @@
|
||||||
"model_unslicable_alt": [172, 172, 127, 255],
|
"model_unslicable_alt": [172, 172, 127, 255],
|
||||||
"model_selection_outline": [12, 169, 227, 255],
|
"model_selection_outline": [12, 169, 227, 255],
|
||||||
|
|
||||||
|
"xray_error_dark": [255, 0, 0, 255],
|
||||||
|
"xray_error_light": [255, 255, 0, 255],
|
||||||
"xray": [26, 26, 62, 255],
|
"xray": [26, 26, 62, 255],
|
||||||
"xray_error": [255, 0, 0, 255],
|
"xray_error": [255, 0, 0, 255],
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,10 @@
|
||||||
"y_axis": [64, 64, 255, 255],
|
"y_axis": [64, 64, 255, 255],
|
||||||
"model_default": [156, 201, 36, 255],
|
"model_default": [156, 201, 36, 255],
|
||||||
"model_overhang": [200, 0, 255, 255],
|
"model_overhang": [200, 0, 255, 255],
|
||||||
|
|
||||||
"model_selection_outline": [12, 169, 227, 255],
|
"model_selection_outline": [12, 169, 227, 255],
|
||||||
|
|
||||||
|
"xray_error_dark": [255, 0, 0, 255],
|
||||||
|
"xray_error_light": [255, 255, 0, 255],
|
||||||
"xray": [26, 26, 62, 255],
|
"xray": [26, 26, 62, 255],
|
||||||
"xray_error": [255, 0, 0, 255],
|
"xray_error": [255, 0, 0, 255],
|
||||||
|
|
||||||
|
|
|
@ -369,6 +369,8 @@
|
||||||
"model_selection_outline": [50, 130, 255, 255],
|
"model_selection_outline": [50, 130, 255, 255],
|
||||||
"model_non_printing": [122, 122, 122, 255],
|
"model_non_printing": [122, 122, 122, 255],
|
||||||
|
|
||||||
|
"xray_error_dark": [255, 0, 0, 255],
|
||||||
|
"xray_error_light": [255, 255, 0, 255],
|
||||||
"xray": [26, 26, 62, 255],
|
"xray": [26, 26, 62, 255],
|
||||||
"xray_error": [255, 0, 0, 255],
|
"xray_error": [255, 0, 0, 255],
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue