mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 23:53:56 -06:00
Merge pull request #1405 from Ultimaker/opengl41core
Opengl41core - on top of layer_view3_cleanup
This commit is contained in:
commit
f571c5ea8e
11 changed files with 292 additions and 46 deletions
|
@ -223,6 +223,7 @@ class CuraApplication(QtApplication):
|
||||||
Preferences.getInstance().addPreference("mesh/scale_tiny_meshes", True)
|
Preferences.getInstance().addPreference("mesh/scale_tiny_meshes", True)
|
||||||
Preferences.getInstance().addPreference("cura/dialog_on_project_save", True)
|
Preferences.getInstance().addPreference("cura/dialog_on_project_save", True)
|
||||||
Preferences.getInstance().addPreference("cura/asked_dialog_on_project_save", False)
|
Preferences.getInstance().addPreference("cura/asked_dialog_on_project_save", False)
|
||||||
|
Preferences.getInstance().addPreference("view/force_layer_view_compatibility_mode", False)
|
||||||
|
|
||||||
Preferences.getInstance().addPreference("cura/currency", "€")
|
Preferences.getInstance().addPreference("cura/currency", "€")
|
||||||
Preferences.getInstance().addPreference("cura/material_settings", "{}")
|
Preferences.getInstance().addPreference("cura/material_settings", "{}")
|
||||||
|
|
|
@ -9,6 +9,7 @@ from UM.Scene.SceneNode import SceneNode
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
from UM.Mesh.MeshData import MeshData
|
from UM.Mesh.MeshData import MeshData
|
||||||
from UM.Preferences import Preferences
|
from UM.Preferences import Preferences
|
||||||
|
from UM.View.GL.OpenGLContext import OpenGLContext
|
||||||
|
|
||||||
from UM.Message import Message
|
from UM.Message import Message
|
||||||
from UM.i18n import i18nCatalog
|
from UM.i18n import i18nCatalog
|
||||||
|
@ -180,10 +181,10 @@ class ProcessSlicedLayersJob(Job):
|
||||||
material_color_map[0, :] = color
|
material_color_map[0, :] = color
|
||||||
|
|
||||||
# We have to scale the colors for compatibility mode
|
# We have to scale the colors for compatibility mode
|
||||||
if Application.getInstance().getRenderer().getSupportsGeometryShader():
|
if OpenGLContext.isLegacyOpenGL() or bool(Preferences.getInstance().getValue("view/force_layer_view_compatibility_mode")):
|
||||||
line_type_brightness = 1.0
|
|
||||||
else:
|
|
||||||
line_type_brightness = 0.5 # for compatibility mode
|
line_type_brightness = 0.5 # for compatibility mode
|
||||||
|
else:
|
||||||
|
line_type_brightness = 1.0
|
||||||
layer_mesh = layer_data.build(material_color_map, line_type_brightness)
|
layer_mesh = layer_data.build(material_color_map, line_type_brightness)
|
||||||
|
|
||||||
if self._abort_requested:
|
if self._abort_requested:
|
||||||
|
|
|
@ -14,6 +14,7 @@ from UM.View.GL.OpenGL import OpenGL
|
||||||
|
|
||||||
from cura.Settings.ExtruderManager import ExtruderManager
|
from cura.Settings.ExtruderManager import ExtruderManager
|
||||||
|
|
||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
## RenderPass used to display g-code paths.
|
## RenderPass used to display g-code paths.
|
||||||
|
|
|
@ -16,6 +16,7 @@ from UM.Logger import Logger
|
||||||
from UM.View.GL.OpenGL import OpenGL
|
from UM.View.GL.OpenGL import OpenGL
|
||||||
from UM.Message import Message
|
from UM.Message import Message
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
|
from UM.View.GL.OpenGLContext import OpenGLContext
|
||||||
|
|
||||||
from cura.ConvexHullNode import ConvexHullNode
|
from cura.ConvexHullNode import ConvexHullNode
|
||||||
from cura.Settings.ExtruderManager import ExtruderManager
|
from cura.Settings.ExtruderManager import ExtruderManager
|
||||||
|
@ -65,7 +66,6 @@ class LayerView(View):
|
||||||
|
|
||||||
Preferences.getInstance().addPreference("view/top_layer_count", 5)
|
Preferences.getInstance().addPreference("view/top_layer_count", 5)
|
||||||
Preferences.getInstance().addPreference("view/only_show_top_layers", False)
|
Preferences.getInstance().addPreference("view/only_show_top_layers", False)
|
||||||
Preferences.getInstance().addPreference("view/compatibility_mode", True) # Default True for now, needs testing of different computers
|
|
||||||
|
|
||||||
Preferences.getInstance().preferenceChanged.connect(self._onPreferencesChanged)
|
Preferences.getInstance().preferenceChanged.connect(self._onPreferencesChanged)
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ class LayerView(View):
|
||||||
# Currently the RenderPass constructor requires a size > 0
|
# Currently the RenderPass constructor requires a size > 0
|
||||||
# This should be fixed in RenderPass's constructor.
|
# This should be fixed in RenderPass's constructor.
|
||||||
self._layer_pass = LayerPass.LayerPass(1, 1)
|
self._layer_pass = LayerPass.LayerPass(1, 1)
|
||||||
self._compatibility_mode = not self.getRenderer().getSupportsGeometryShader()
|
self._compatibility_mode = OpenGLContext.isLegacyOpenGL() or bool(Preferences.getInstance().getValue("view/force_layer_view_compatibility_mode"))
|
||||||
self._layer_pass.setLayerView(self)
|
self._layer_pass.setLayerView(self)
|
||||||
self.getRenderer().addRenderPass(self._layer_pass)
|
self.getRenderer().addRenderPass(self._layer_pass)
|
||||||
return self._layer_pass
|
return self._layer_pass
|
||||||
|
|
|
@ -174,7 +174,7 @@ Item
|
||||||
ComboBox
|
ComboBox
|
||||||
{
|
{
|
||||||
id: layerTypeCombobox
|
id: layerTypeCombobox
|
||||||
anchors.top: slider_background.bottom
|
anchors.top: parent.top
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
model: layerViewTypes
|
model: layerViewTypes
|
||||||
visible: !UM.LayerView.compatibilityMode
|
visible: !UM.LayerView.compatibilityMode
|
||||||
|
@ -186,7 +186,7 @@ Item
|
||||||
Label
|
Label
|
||||||
{
|
{
|
||||||
id: compatibilityModeLabel
|
id: compatibilityModeLabel
|
||||||
anchors.top: slider_background.bottom
|
anchors.top: parent.top
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
text: catalog.i18nc("@label","Compatibility mode")
|
text: catalog.i18nc("@label","Compatibility mode")
|
||||||
visible: UM.LayerView.compatibilityMode
|
visible: UM.LayerView.compatibilityMode
|
||||||
|
|
|
@ -4,10 +4,9 @@ vertex =
|
||||||
uniform lowp float u_active_extruder;
|
uniform lowp float u_active_extruder;
|
||||||
uniform lowp float u_shade_factor;
|
uniform lowp float u_shade_factor;
|
||||||
uniform highp int u_layer_view_type;
|
uniform highp int u_layer_view_type;
|
||||||
uniform highp int u_only_color_active_extruder;
|
|
||||||
|
|
||||||
attribute highp int a_extruder;
|
attribute highp float a_extruder;
|
||||||
attribute highp int a_line_type;
|
attribute highp float a_line_type;
|
||||||
attribute highp vec4 a_vertex;
|
attribute highp vec4 a_vertex;
|
||||||
attribute lowp vec4 a_color;
|
attribute lowp vec4 a_color;
|
||||||
attribute lowp vec4 a_material_color;
|
attribute lowp vec4 a_material_color;
|
||||||
|
@ -19,10 +18,7 @@ vertex =
|
||||||
{
|
{
|
||||||
gl_Position = u_modelViewProjectionMatrix * a_vertex;
|
gl_Position = u_modelViewProjectionMatrix * a_vertex;
|
||||||
v_color = a_color;
|
v_color = a_color;
|
||||||
if ((u_only_color_active_extruder == 1) && (a_line_type != 8) && (a_line_type != 9)) {
|
if ((a_line_type != 8.0) && (a_line_type != 9.0)) {
|
||||||
v_color = (a_extruder == u_active_extruder) ? v_color : vec4(0.4, 0.4, 0.4, v_color.a);
|
|
||||||
}
|
|
||||||
if ((u_only_color_active_extruder == 0) && (a_line_type != 8) && (a_line_type != 9)) {
|
|
||||||
v_color = (a_extruder == u_active_extruder) ? v_color : vec4(u_shade_factor * v_color.rgb, v_color.a);
|
v_color = (a_extruder == u_active_extruder) ? v_color : vec4(u_shade_factor * v_color.rgb, v_color.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,11 +69,83 @@ fragment =
|
||||||
gl_FragColor = v_color;
|
gl_FragColor = v_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vertex41core =
|
||||||
|
#version 410
|
||||||
|
uniform highp mat4 u_modelViewProjectionMatrix;
|
||||||
|
uniform lowp float u_active_extruder;
|
||||||
|
uniform lowp float u_shade_factor;
|
||||||
|
uniform highp int u_layer_view_type;
|
||||||
|
|
||||||
|
in highp int a_extruder;
|
||||||
|
in highp int a_line_type;
|
||||||
|
in highp vec4 a_vertex;
|
||||||
|
in lowp vec4 a_color;
|
||||||
|
in lowp vec4 a_material_color;
|
||||||
|
|
||||||
|
out lowp vec4 v_color;
|
||||||
|
out float v_line_type;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = u_modelViewProjectionMatrix * a_vertex;
|
||||||
|
v_color = a_color;
|
||||||
|
if ((a_line_type != 8) && (a_line_type != 9)) {
|
||||||
|
v_color = (a_extruder == u_active_extruder) ? v_color : vec4(u_shade_factor * v_color.rgb, v_color.a);
|
||||||
|
}
|
||||||
|
|
||||||
|
v_line_type = a_line_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment41core =
|
||||||
|
#version 410
|
||||||
|
in lowp vec4 v_color;
|
||||||
|
in float v_line_type;
|
||||||
|
out vec4 frag_color;
|
||||||
|
|
||||||
|
uniform int u_show_travel_moves;
|
||||||
|
uniform int u_show_support;
|
||||||
|
uniform int u_show_adhesion;
|
||||||
|
uniform int u_show_skin;
|
||||||
|
uniform int u_show_infill;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
if ((u_show_travel_moves == 0) && (v_line_type >= 7.5) && (v_line_type <= 9.5)) { // actually, 8 and 9
|
||||||
|
// discard movements
|
||||||
|
discard;
|
||||||
|
}
|
||||||
|
// support: 4, 7, 10
|
||||||
|
if ((u_show_support == 0) && (
|
||||||
|
((v_line_type >= 3.5) && (v_line_type <= 4.5)) ||
|
||||||
|
((v_line_type >= 6.5) && (v_line_type <= 7.5)) ||
|
||||||
|
((v_line_type >= 9.5) && (v_line_type <= 10.5))
|
||||||
|
)) {
|
||||||
|
discard;
|
||||||
|
}
|
||||||
|
// skin: 1, 2, 3
|
||||||
|
if ((u_show_skin == 0) && (
|
||||||
|
(v_line_type >= 0.5) && (v_line_type <= 3.5)
|
||||||
|
)) {
|
||||||
|
discard;
|
||||||
|
}
|
||||||
|
// adhesion:
|
||||||
|
if ((u_show_adhesion == 0) && (v_line_type >= 4.5) && (v_line_type <= 5.5)) {
|
||||||
|
// discard movements
|
||||||
|
discard;
|
||||||
|
}
|
||||||
|
// infill:
|
||||||
|
if ((u_show_infill == 0) && (v_line_type >= 5.5) && (v_line_type <= 6.5)) {
|
||||||
|
// discard movements
|
||||||
|
discard;
|
||||||
|
}
|
||||||
|
|
||||||
|
frag_color = v_color;
|
||||||
|
}
|
||||||
|
|
||||||
[defaults]
|
[defaults]
|
||||||
u_active_extruder = 0.0
|
u_active_extruder = 0.0
|
||||||
u_shade_factor = 0.60
|
u_shade_factor = 0.60
|
||||||
u_layer_view_type = 0
|
u_layer_view_type = 0
|
||||||
u_only_color_active_extruder = 1
|
|
||||||
u_extruder_opacity = [1.0, 1.0, 1.0, 1.0]
|
u_extruder_opacity = [1.0, 1.0, 1.0, 1.0]
|
||||||
|
|
||||||
u_show_travel_moves = 0
|
u_show_travel_moves = 0
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
[shaders]
|
[shaders]
|
||||||
vertex =
|
vertex41core =
|
||||||
#version 410
|
#version 410
|
||||||
|
uniform highp mat4 u_modelViewProjectionMatrix;
|
||||||
|
|
||||||
uniform highp mat4 u_modelMatrix;
|
uniform highp mat4 u_modelMatrix;
|
||||||
uniform highp mat4 u_viewProjectionMatrix;
|
uniform highp mat4 u_viewProjectionMatrix;
|
||||||
uniform lowp float u_active_extruder;
|
uniform lowp float u_active_extruder;
|
||||||
|
@ -9,27 +11,26 @@ vertex =
|
||||||
|
|
||||||
uniform highp mat4 u_normalMatrix;
|
uniform highp mat4 u_normalMatrix;
|
||||||
|
|
||||||
attribute highp vec4 a_vertex;
|
in highp vec4 a_vertex;
|
||||||
attribute lowp vec4 a_color;
|
in lowp vec4 a_color;
|
||||||
attribute lowp vec4 a_material_color;
|
in lowp vec4 a_material_color;
|
||||||
attribute highp vec4 a_normal;
|
in highp vec4 a_normal;
|
||||||
attribute highp vec2 a_line_dim; // line width and thickness
|
in highp vec2 a_line_dim; // line width and thickness
|
||||||
attribute highp int a_extruder;
|
in highp int a_extruder;
|
||||||
attribute highp int a_line_type;
|
in highp int a_line_type;
|
||||||
|
|
||||||
varying lowp vec4 v_color;
|
out lowp vec4 v_color;
|
||||||
|
|
||||||
varying highp vec3 v_vertex;
|
out highp vec3 v_vertex;
|
||||||
varying highp vec3 v_normal;
|
out highp vec3 v_normal;
|
||||||
varying lowp vec2 v_line_dim;
|
out lowp vec2 v_line_dim;
|
||||||
varying highp int v_extruder;
|
out highp int v_extruder;
|
||||||
varying highp vec4 v_extruder_opacity;
|
out highp vec4 v_extruder_opacity;
|
||||||
varying int v_line_type;
|
out int v_line_type;
|
||||||
|
|
||||||
varying lowp vec4 f_color;
|
out lowp vec4 f_color;
|
||||||
varying highp vec3 f_vertex;
|
out highp vec3 f_vertex;
|
||||||
varying highp vec3 f_normal;
|
out highp vec3 f_normal;
|
||||||
varying highp int f_extruder;
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
@ -56,13 +57,13 @@ vertex =
|
||||||
v_line_type = a_line_type;
|
v_line_type = a_line_type;
|
||||||
v_extruder_opacity = u_extruder_opacity;
|
v_extruder_opacity = u_extruder_opacity;
|
||||||
|
|
||||||
// for testing and backwards compatibility without geometry shader
|
// for testing without geometry shader
|
||||||
/*f_color = v_color;
|
f_color = v_color;
|
||||||
f_vertex = v_vertex;
|
f_vertex = v_vertex;
|
||||||
f_normal = v_normal;*/
|
f_normal = v_normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
geometry =
|
geometry41core =
|
||||||
#version 410
|
#version 410
|
||||||
|
|
||||||
uniform highp mat4 u_viewProjectionMatrix;
|
uniform highp mat4 u_viewProjectionMatrix;
|
||||||
|
@ -86,7 +87,6 @@ geometry =
|
||||||
out vec4 f_color;
|
out vec4 f_color;
|
||||||
out vec3 f_normal;
|
out vec3 f_normal;
|
||||||
out vec3 f_vertex;
|
out vec3 f_vertex;
|
||||||
out uint f_extruder;
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
@ -130,8 +130,6 @@ geometry =
|
||||||
size_y = v_line_dim[0].y / 2 + 0.01;
|
size_y = v_line_dim[0].y / 2 + 0.01;
|
||||||
}
|
}
|
||||||
|
|
||||||
f_extruder = v_extruder[0];
|
|
||||||
|
|
||||||
g_vertex_delta = gl_in[1].gl_Position - gl_in[0].gl_Position;
|
g_vertex_delta = gl_in[1].gl_Position - gl_in[0].gl_Position;
|
||||||
g_vertex_normal_horz_head = normalize(vec3(-g_vertex_delta.x, -g_vertex_delta.y, -g_vertex_delta.z));
|
g_vertex_normal_horz_head = normalize(vec3(-g_vertex_delta.x, -g_vertex_delta.y, -g_vertex_delta.z));
|
||||||
g_vertex_offset_horz_head = vec4(g_vertex_normal_horz_head * size_x, 0.0);
|
g_vertex_offset_horz_head = vec4(g_vertex_normal_horz_head * size_x, 0.0);
|
||||||
|
@ -285,11 +283,13 @@ geometry =
|
||||||
EndPrimitive();
|
EndPrimitive();
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment =
|
fragment41core =
|
||||||
#version 410
|
#version 410
|
||||||
varying lowp vec4 f_color;
|
in lowp vec4 f_color;
|
||||||
varying lowp vec3 f_normal;
|
in lowp vec3 f_normal;
|
||||||
varying lowp vec3 f_vertex;
|
in lowp vec3 f_vertex;
|
||||||
|
|
||||||
|
out vec4 frag_color;
|
||||||
|
|
||||||
uniform mediump vec4 u_ambientColor;
|
uniform mediump vec4 u_ambientColor;
|
||||||
uniform highp vec3 u_lightPosition;
|
uniform highp vec3 u_lightPosition;
|
||||||
|
@ -309,7 +309,7 @@ fragment =
|
||||||
finalColor += (NdotL * f_color);
|
finalColor += (NdotL * f_color);
|
||||||
finalColor.a = alpha; // Do not change alpha in any way
|
finalColor.a = alpha; // Do not change alpha in any way
|
||||||
|
|
||||||
gl_FragColor = finalColor;
|
frag_color = finalColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,74 @@ fragment =
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vertex41core =
|
||||||
|
#version 410
|
||||||
|
uniform highp mat4 u_modelViewProjectionMatrix;
|
||||||
|
in highp vec4 a_vertex;
|
||||||
|
in highp vec2 a_uvs;
|
||||||
|
|
||||||
|
out highp vec2 v_uvs;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = u_modelViewProjectionMatrix * a_vertex;
|
||||||
|
v_uvs = a_uvs;
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment41core =
|
||||||
|
#version 410
|
||||||
|
uniform sampler2D u_layer0;
|
||||||
|
uniform sampler2D u_layer1;
|
||||||
|
uniform sampler2D u_layer2;
|
||||||
|
|
||||||
|
uniform vec2 u_offset[9];
|
||||||
|
|
||||||
|
uniform vec4 u_background_color;
|
||||||
|
uniform float u_outline_strength;
|
||||||
|
uniform vec4 u_outline_color;
|
||||||
|
|
||||||
|
in vec2 v_uvs;
|
||||||
|
|
||||||
|
float kernel[9];
|
||||||
|
|
||||||
|
const vec3 x_axis = vec3(1.0, 0.0, 0.0);
|
||||||
|
const vec3 y_axis = vec3(0.0, 1.0, 0.0);
|
||||||
|
const vec3 z_axis = vec3(0.0, 0.0, 1.0);
|
||||||
|
|
||||||
|
out vec4 frag_color;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
kernel[0] = 0.0; kernel[1] = 1.0; kernel[2] = 0.0;
|
||||||
|
kernel[3] = 1.0; kernel[4] = -4.0; kernel[5] = 1.0;
|
||||||
|
kernel[6] = 0.0; kernel[7] = 1.0; kernel[8] = 0.0;
|
||||||
|
|
||||||
|
vec4 result = u_background_color;
|
||||||
|
|
||||||
|
vec4 main_layer = texture(u_layer0, v_uvs);
|
||||||
|
vec4 selection_layer = texture(u_layer1, v_uvs);
|
||||||
|
vec4 layerview_layer = texture(u_layer2, v_uvs);
|
||||||
|
|
||||||
|
result = main_layer * main_layer.a + result * (1.0 - main_layer.a);
|
||||||
|
result = layerview_layer * layerview_layer.a + result * (1.0 - layerview_layer.a);
|
||||||
|
|
||||||
|
vec4 sum = vec4(0.0);
|
||||||
|
for (int i = 0; i < 9; i++)
|
||||||
|
{
|
||||||
|
vec4 color = vec4(texture(u_layer1, v_uvs.xy + u_offset[i]).a);
|
||||||
|
sum += color * (kernel[i] / u_outline_strength);
|
||||||
|
}
|
||||||
|
|
||||||
|
if((selection_layer.rgb == x_axis || selection_layer.rgb == y_axis || selection_layer.rgb == z_axis))
|
||||||
|
{
|
||||||
|
frag_color = result;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
frag_color = mix(result, u_outline_color, abs(sum.a));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[defaults]
|
[defaults]
|
||||||
u_layer0 = 0
|
u_layer0 = 0
|
||||||
u_layer1 = 1
|
u_layer1 = 1
|
||||||
|
|
|
@ -17,6 +17,28 @@ fragment =
|
||||||
gl_FragColor = u_color;
|
gl_FragColor = u_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vertex41core =
|
||||||
|
#version 410
|
||||||
|
uniform highp mat4 u_modelViewProjectionMatrix;
|
||||||
|
|
||||||
|
in highp vec4 a_vertex;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = u_modelViewProjectionMatrix * a_vertex;
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment41core =
|
||||||
|
#version 410
|
||||||
|
uniform lowp vec4 u_color;
|
||||||
|
|
||||||
|
out vec4 frag_color;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
frag_color = u_color;
|
||||||
|
}
|
||||||
|
|
||||||
[defaults]
|
[defaults]
|
||||||
u_color = [0.02, 0.02, 0.02, 1.0]
|
u_color = [0.02, 0.02, 0.02, 1.0]
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,77 @@ fragment =
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vertex41core =
|
||||||
|
#version 410
|
||||||
|
uniform highp mat4 u_modelViewProjectionMatrix;
|
||||||
|
in highp vec4 a_vertex;
|
||||||
|
in highp vec2 a_uvs;
|
||||||
|
|
||||||
|
out highp vec2 v_uvs;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = u_modelViewProjectionMatrix * a_vertex;
|
||||||
|
v_uvs = a_uvs;
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment41core =
|
||||||
|
#version 410
|
||||||
|
uniform sampler2D u_layer0;
|
||||||
|
uniform sampler2D u_layer1;
|
||||||
|
uniform sampler2D u_layer2;
|
||||||
|
|
||||||
|
uniform vec2 u_offset[9];
|
||||||
|
|
||||||
|
uniform float u_outline_strength;
|
||||||
|
uniform vec4 u_outline_color;
|
||||||
|
uniform vec4 u_error_color;
|
||||||
|
uniform vec4 u_background_color;
|
||||||
|
|
||||||
|
const vec3 x_axis = vec3(1.0, 0.0, 0.0);
|
||||||
|
const vec3 y_axis = vec3(0.0, 1.0, 0.0);
|
||||||
|
const vec3 z_axis = vec3(0.0, 0.0, 1.0);
|
||||||
|
|
||||||
|
in vec2 v_uvs;
|
||||||
|
out vec4 frag_color;
|
||||||
|
|
||||||
|
float kernel[9];
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
kernel[0] = 0.0; kernel[1] = 1.0; kernel[2] = 0.0;
|
||||||
|
kernel[3] = 1.0; kernel[4] = -4.0; kernel[5] = 1.0;
|
||||||
|
kernel[6] = 0.0; kernel[7] = 1.0; kernel[8] = 0.0;
|
||||||
|
|
||||||
|
vec4 result = u_background_color;
|
||||||
|
vec4 layer0 = texture(u_layer0, v_uvs);
|
||||||
|
|
||||||
|
result = layer0 * layer0.a + result * (1.0 - layer0.a);
|
||||||
|
|
||||||
|
float intersection_count = (texture(u_layer2, v_uvs).r * 255.0) / 5.0;
|
||||||
|
if(mod(intersection_count, 2.0) == 1.0)
|
||||||
|
{
|
||||||
|
result = u_error_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 sum = vec4(0.0);
|
||||||
|
for (int i = 0; i < 9; i++)
|
||||||
|
{
|
||||||
|
vec4 color = vec4(texture(u_layer1, v_uvs.xy + u_offset[i]).a);
|
||||||
|
sum += color * (kernel[i] / u_outline_strength);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 layer1 = texture(u_layer1, v_uvs);
|
||||||
|
if((layer1.rgb == x_axis || layer1.rgb == y_axis || layer1.rgb == z_axis))
|
||||||
|
{
|
||||||
|
frag_color = result;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
frag_color = mix(result, vec4(abs(sum.a)) * u_outline_color, abs(sum.a));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[defaults]
|
[defaults]
|
||||||
u_layer0 = 0
|
u_layer0 = 0
|
||||||
u_layer1 = 1
|
u_layer1 = 1
|
||||||
|
|
|
@ -265,6 +265,20 @@ UM.PreferencesPage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UM.TooltipArea {
|
||||||
|
width: childrenRect.width
|
||||||
|
height: childrenRect.height
|
||||||
|
text: catalog.i18nc("@info:tooltip", "Should layer be forced into compatibility mode?")
|
||||||
|
|
||||||
|
CheckBox
|
||||||
|
{
|
||||||
|
id: forceLayerViewCompatibilityModeCheckbox
|
||||||
|
text: catalog.i18nc("@option:check", "Force layer view compatibility mode (restart required)")
|
||||||
|
checked: boolCheck(UM.Preferences.getValue("view/force_layer_view_compatibility_mode"))
|
||||||
|
onCheckedChanged: UM.Preferences.setValue("view/force_layer_view_compatibility_mode", checked)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Item
|
Item
|
||||||
{
|
{
|
||||||
//: Spacer
|
//: Spacer
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue