diff --git a/plugins/SolidView/SolidView.py b/plugins/SolidView/SolidView.py index 8600234173..94aa648197 100644 --- a/plugins/SolidView/SolidView.py +++ b/plugins/SolidView/SolidView.py @@ -44,7 +44,6 @@ class SolidView(View): 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 @@ -127,7 +126,6 @@ class SolidView(View): 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")) @@ -138,8 +136,6 @@ class SolidView(View): self._xray_composite_shader.setUniformValue("u_background_color", Color(*theme.getColor("viewport_background").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 diff --git a/plugins/SolidView/xray_composite.shader b/plugins/SolidView/xray_composite.shader index f24d14f165..9a28e05013 100644 --- a/plugins/SolidView/xray_composite.shader +++ b/plugins/SolidView/xray_composite.shader @@ -31,7 +31,6 @@ fragment = uniform vec4 u_outline_color; 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,7 +61,8 @@ fragment = float intersection_count = texture2D(u_layer2, v_uvs).r * 255.0; if(mod(intersection_count, 2.0) >= 1.0) { - result = result * (1.0 - u_xray_error_strength) + u_xray_error_strength * texture(u_xray_error, v_uvs * u_xray_error_img_scaling); + vec2 scaling = textureSize(u_layer0, 0) / textureSize(u_xray_error, 0); + result = result * (1.0 - u_xray_error_strength) + u_xray_error_strength * texture(u_xray_error, v_uvs * scaling); } vec4 sum = vec4(0.0); @@ -112,7 +112,6 @@ fragment41core = uniform vec4 u_outline_color; 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); @@ -144,7 +143,8 @@ fragment41core = float intersection_count = texture(u_layer2, v_uvs).r * 255.0; if(mod(intersection_count, 2.0) >= 1.0) { - result = result * (1.0 - u_xray_error_strength) + u_xray_error_strength * texture(u_xray_error, v_uvs * u_xray_error_img_scaling); + vec2 scaling = textureSize(u_layer0, 0) / textureSize(u_xray_error, 0); + result = result * (1.0 - u_xray_error_strength) + u_xray_error_strength * texture(u_xray_error, v_uvs * scaling); } vec4 sum = vec4(0.0); @@ -176,7 +176,6 @@ 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_xray_error_strength = 0.4 -u_xray_error_img_scaling = [1.0,1.0] [bindings]