Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Vazquez <pablovazquez>2021-10-21 22:00:17 +0300
committerPablo Vazquez <pablo@blender.org>2021-10-21 22:00:38 +0300
commit9b1b4b9e32c8ac86e460204bb93e0ddc42ad9e49 (patch)
tree564dd67518d0f5d504de2b30a871a46401f97720 /source/blender/gpu
parent1d96a482675dd2ccad2af31c274f74b9f6603d6b (diff)
Node Editor: Introduce color overlay and dashed wires theme setting
This patch includes code from D9891 and D12754, so credit goes to Juanfran and Dalai. I updated the patches to work with `master` and with the new overlay toggle. The reason to include both changes as part of one patch is that the dimmed dashed lines work much better together with colored wires. Theme setting for dash opacity: {F11370574, size=full} {F11286177, size=full, autoplay, loop} {F11149912, size=full} For adding the overlay I used `SpaceImageOverlay` as reference, although I'm not familiar with this code so there might be mistakes. Reviewed By: #user_interface, HooglyBoogly Differential Revision: https://developer.blender.org/D12886
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_nodelink_frag.glsl6
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl25
2 files changed, 26 insertions, 5 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_nodelink_frag.glsl b/source/blender/gpu/shaders/gpu_shader_2D_nodelink_frag.glsl
index 402a07ad4e8..134a7d00127 100644
--- a/source/blender/gpu/shaders/gpu_shader_2D_nodelink_frag.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_2D_nodelink_frag.glsl
@@ -4,12 +4,14 @@ in vec4 finalColor;
in float lineU;
flat in float lineLength;
flat in float dashFactor;
+flat in float dashAlpha;
flat in int isMainLine;
out vec4 fragColor;
-#define DASH_WIDTH 20.0
+#define DASH_WIDTH 10.0
#define ANTIALIAS 1.0
+#define MINIMUM_ALPHA 0.5
void main()
{
@@ -29,7 +31,7 @@ void main()
float slope = 1.0 / (2.0 * t);
float unclamped_alpha = 1.0 - slope * (normalized_distance_triangle - dashFactor + t);
- float alpha = max(0.0, min(unclamped_alpha, 1.0));
+ float alpha = max(dashAlpha, min(unclamped_alpha, 1.0));
fragColor.a *= alpha;
}
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl
index 8f46c8eda4b..acc7030415f 100644
--- a/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl
@@ -17,15 +17,18 @@ in vec2 P1;
in vec2 P2;
in vec2 P3;
in ivec4 colid_doarrow;
+in vec4 start_color;
+in vec4 end_color;
in ivec2 domuted;
in float dim_factor;
in float thickness;
in float dash_factor;
+in float dash_alpha;
uniform vec4 colors[6];
-# define colStart colors[colid_doarrow[0]]
-# define colEnd colors[colid_doarrow[1]]
+# define colStart (colid_doarrow[0] < 3 ? start_color : colors[colid_doarrow[0]])
+# define colEnd (colid_doarrow[1] < 3 ? end_color : colors[colid_doarrow[1]])
# define colShadow colors[colid_doarrow[2]]
# define doArrow (colid_doarrow[3] != 0)
# define doMuted (domuted[0] != 0)
@@ -61,13 +64,20 @@ out vec4 finalColor;
out float lineU;
flat out float lineLength;
flat out float dashFactor;
+flat out float dashAlpha;
flat out int isMainLine;
+/* Define where along the noodle the gradient will starts and ends.
+ * Use 0.25 instead of 0.35-0.65, because of a visual shift issue. */
+const float start_gradient_threshold = 0.25;
+const float end_gradient_threshold = 0.55;
+
void main(void)
{
/* Parameters for the dashed line. */
isMainLine = expand.y != 1.0 ? 0 : 1;
dashFactor = dash_factor;
+ dashAlpha = dash_alpha;
/* Approximate line length, no need for real bezier length calculation. */
lineLength = distance(P0, P3);
/* TODO: Incorrect U, this leads to non-uniform dash distribution. */
@@ -109,7 +119,16 @@ void main(void)
}
else {
/* Second pass */
- finalColor = mix(colStart, colEnd, uv.x);
+ if (uv.x < start_gradient_threshold) {
+ finalColor = colStart;
+ }
+ else if (uv.x > end_gradient_threshold) {
+ finalColor = colEnd;
+ }
+ else {
+ /* Add 0.1 to avoid a visual shift issue. */
+ finalColor = mix(colStart, colEnd, uv.x + 0.1);
+ }
expand_dist *= 0.5;
if (doMuted) {
finalColor[3] = 0.65;