mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
use tiled image for xray error instead of a uniform color
temporarily use the cura logo as placeholder image didn't correctly determine window size yet
This commit is contained in:
parent
82b2f23689
commit
0f184219e6
2 changed files with 23 additions and 30 deletions
|
@ -6,7 +6,7 @@ from UM.View.View import View
|
|||
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
|
||||
from UM.Scene.Selection import Selection
|
||||
from UM.Resources import Resources
|
||||
from PyQt5.QtGui import QOpenGLContext
|
||||
from PyQt5.QtGui import QOpenGLContext, QImage
|
||||
|
||||
from UM.Application import Application
|
||||
from UM.Logger import Logger
|
||||
|
@ -43,6 +43,8 @@ class SolidView(View):
|
|||
self._xray_pass = None
|
||||
self._xray_composite_shader = None
|
||||
self._composite_pass = None
|
||||
self._xray_error_image = None
|
||||
self._xray_error_image_size = None
|
||||
|
||||
self._extruders_model = None
|
||||
self._theme = None
|
||||
|
@ -118,6 +120,15 @@ class SolidView(View):
|
|||
|
||||
self._checkSetup()
|
||||
|
||||
if not self._xray_error_image:
|
||||
self._xray_error_image = OpenGL.getInstance().createTexture()
|
||||
texture_file = "cura-icon-32.png" #TODO make an img for this!
|
||||
try:
|
||||
self._xray_error_image.load(Resources.getPath(Resources.Images, texture_file))
|
||||
except FileNotFoundError:
|
||||
Logger.log("w", "Unable to find xray error texture image [%s]", texture_file)
|
||||
self._xray_error_image_size = QImage(Resources.getPath(Resources.Images, texture_file)).size()
|
||||
|
||||
if not self._xray_shader:
|
||||
self._xray_shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "xray.shader"))
|
||||
|
||||
|
@ -125,9 +136,10 @@ 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_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.setTexture(3, self._xray_error_image)
|
||||
[ww,wh] = [1920,1080]
|
||||
self._xray_composite_shader.setUniformValue("u_xray_error_img_scaling", [ww / self._xray_error_image_size.width(), wh / self._xray_error_image_size.height()])
|
||||
|
||||
if not self.getRenderer().getRenderPass("xray"):
|
||||
# Currently the RenderPass constructor requires a size > 0
|
||||
|
|
|
@ -23,15 +23,15 @@ fragment =
|
|||
uniform sampler2D u_layer0; //Default pass.
|
||||
uniform sampler2D u_layer1; //Selection pass.
|
||||
uniform sampler2D u_layer2; //X-ray pass.
|
||||
uniform sampler2D u_xray_error; //X-ray error image.
|
||||
|
||||
uniform vec2 u_offset[9];
|
||||
|
||||
uniform float u_outline_strength;
|
||||
uniform vec4 u_outline_color;
|
||||
uniform vec4 u_xray_error_dark;
|
||||
uniform vec4 u_xray_error_light;
|
||||
uniform vec4 u_background_color;
|
||||
uniform float u_xray_error_strength;
|
||||
uniform vec2 u_xray_error_img_scaling;
|
||||
|
||||
const vec3 x_axis = vec3(1.0, 0.0, 0.0);
|
||||
const vec3 y_axis = vec3(0.0, 1.0, 0.0);
|
||||
|
@ -62,16 +62,7 @@ fragment =
|
|||
float intersection_count = texture2D(u_layer2, v_uvs).r * 255.0;
|
||||
if(mod(intersection_count, 2.0) >= 1.0)
|
||||
{
|
||||
float lightness = (result.r + result.g + result.b) / 3.0;
|
||||
//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_xray_error_dark;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = result * (1.0 - u_xray_error_strength) + u_xray_error_strength * u_xray_error_light;
|
||||
}
|
||||
result = result * (1.0 - u_xray_error_strength) + u_xray_error_strength * texture(u_xray_error, v_uvs * u_xray_error_img_scaling);
|
||||
}
|
||||
|
||||
vec4 sum = vec4(0.0);
|
||||
|
@ -113,15 +104,15 @@ fragment41core =
|
|||
uniform sampler2D u_layer0; //Default pass.
|
||||
uniform sampler2D u_layer1; //Selection pass.
|
||||
uniform sampler2D u_layer2; //X-ray pass.
|
||||
uniform sampler2D u_xray_error; //X-ray error image.
|
||||
|
||||
uniform vec2 u_offset[9];
|
||||
|
||||
uniform float u_outline_strength;
|
||||
uniform vec4 u_outline_color;
|
||||
uniform vec4 u_xray_error_dark;
|
||||
uniform vec4 u_xray_error_light;
|
||||
uniform vec4 u_background_color;
|
||||
uniform float u_xray_error_strength;
|
||||
uniform vec2 u_xray_error_img_scaling;
|
||||
|
||||
const vec3 x_axis = vec3(1.0, 0.0, 0.0);
|
||||
const vec3 y_axis = vec3(0.0, 1.0, 0.0);
|
||||
|
@ -153,16 +144,7 @@ fragment41core =
|
|||
float intersection_count = texture(u_layer2, v_uvs).r * 255.0;
|
||||
if(mod(intersection_count, 2.0) >= 1.0)
|
||||
{
|
||||
float lightness = (result.r + result.g + result.b) / 3.0;
|
||||
//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_xray_error_dark;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = result * (1.0 - u_xray_error_strength) + u_xray_error_strength * u_xray_error_light;
|
||||
}
|
||||
result = result * (1.0 - u_xray_error_strength) + u_xray_error_strength * texture(u_xray_error, v_uvs * u_xray_error_img_scaling);
|
||||
}
|
||||
|
||||
vec4 sum = vec4(0.0);
|
||||
|
@ -189,13 +171,12 @@ fragment41core =
|
|||
u_layer0 = 0
|
||||
u_layer1 = 1
|
||||
u_layer2 = 2
|
||||
u_xray_error = 3
|
||||
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 = [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_img_scaling = [1.0,1.0]
|
||||
|
||||
[bindings]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue