diff options
author | Tim Kuipers <t.kuipers@ultimaker.com> | 2019-10-22 14:46:39 +0300 |
---|---|---|
committer | Tim Kuipers <t.kuipers@ultimaker.com> | 2020-02-27 18:41:20 +0300 |
commit | 82b2f236896cd77f7b8c233d0ce89399ba44d31e (patch) | |
tree | 80c44bea6f8ca43727038cb39e314322bbab7a76 /plugins/SolidView | |
parent | 1b2cc7f7a78ae92ccad0962381b6f013d984c3e0 (diff) |
make xray solid color depending on what it occludes
Diffstat (limited to 'plugins/SolidView')
-rw-r--r-- | plugins/SolidView/SolidView.py | 3 | ||||
-rw-r--r-- | plugins/SolidView/xray_composite.shader | 24 |
2 files changed, 17 insertions, 10 deletions
diff --git a/plugins/SolidView/SolidView.py b/plugins/SolidView/SolidView.py index bf8eb67782..478cf7331b 100644 --- a/plugins/SolidView/SolidView.py +++ b/plugins/SolidView/SolidView.py @@ -125,7 +125,8 @@ class SolidView(View): self._xray_composite_shader = OpenGL.getInstance().createShaderProgram(os.path.join(PluginRegistry.getInstance().getPluginPath("SolidView"), "xray_composite.shader")) theme = Application.getInstance().getTheme() 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())) if not self.getRenderer().getRenderPass("xray"): diff --git a/plugins/SolidView/xray_composite.shader b/plugins/SolidView/xray_composite.shader index d5732d3757..75bbbf22ec 100644 --- a/plugins/SolidView/xray_composite.shader +++ b/plugins/SolidView/xray_composite.shader @@ -28,7 +28,8 @@ fragment = uniform float u_outline_strength; 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 float u_xray_error_strength; @@ -62,13 +63,14 @@ fragment = if(mod(intersection_count, 2.0) >= 1.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 { - 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 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 float u_xray_error_strength; @@ -151,13 +154,14 @@ fragment41core = if(mod(intersection_count, 2.0) >= 1.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 { - 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_outline_strength = 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 [bindings] |