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
41 lines
1.1 KiB
GLSL
41 lines
1.1 KiB
GLSL
|
|
in float colorGradient;
|
|
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 10.0
|
|
#define ANTIALIAS 1.0
|
|
#define MINIMUM_ALPHA 0.5
|
|
|
|
void main()
|
|
{
|
|
fragColor = finalColor;
|
|
|
|
if ((isMainLine != 0) && (dashFactor < 1.0)) {
|
|
float distance_along_line = lineLength * lineU;
|
|
float normalized_distance = fract(distance_along_line / DASH_WIDTH);
|
|
|
|
/* Checking if `normalized_distance <= dashFactor` is already enough for a basic
|
|
* dash, however we want to handle a nice antialias. */
|
|
|
|
float dash_center = DASH_WIDTH * dashFactor * 0.5;
|
|
float normalized_distance_triangle =
|
|
1.0 - abs((fract((distance_along_line - dash_center) / DASH_WIDTH)) * 2.0 - 1.0);
|
|
float t = ANTIALIAS / DASH_WIDTH;
|
|
float slope = 1.0 / (2.0 * t);
|
|
|
|
float unclamped_alpha = 1.0 - slope * (normalized_distance_triangle - dashFactor + t);
|
|
float alpha = max(dashAlpha, min(unclamped_alpha, 1.0));
|
|
|
|
fragColor.a *= alpha;
|
|
}
|
|
|
|
fragColor.a *= smoothstep(1.0, 0.1, abs(colorGradient));
|
|
}
|