This repository has been archived on 2023-10-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
blender-archive/source/blender/draw/modes/shaders/animviz_mpath_lines_geom.glsl
Campbell Barton e12c08e8d1 ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.

For details on usage and instructions for migrating branches
without conflicts, see:

https://wiki.blender.org/wiki/Tools/ClangFormat
2019-04-17 06:21:24 +02:00

43 lines
1.0 KiB
GLSL

layout(lines) in;
layout(triangle_strip, max_vertices = 4) out;
uniform mat4 ProjectionMatrix;
uniform vec2 viewportSize;
uniform int lineThickness = 2;
in vec4 finalColor_geom[];
in vec2 ssPos[];
out vec4 finalColor;
vec2 compute_dir(vec2 v0, vec2 v1)
{
vec2 dir = normalize(v1 - v0 + 1e-8);
dir = vec2(-dir.y, dir.x);
return dir;
}
void main(void)
{
vec2 t;
vec2 edge_dir = compute_dir(ssPos[0], ssPos[1]) / viewportSize;
bool is_persp = (ProjectionMatrix[3][3] == 0.0);
finalColor = finalColor_geom[0];
t = edge_dir * (float(lineThickness) * (is_persp ? gl_in[0].gl_Position.w : 1.0));
gl_Position = gl_in[0].gl_Position + vec4(t, 0.0, 0.0);
EmitVertex();
gl_Position = gl_in[0].gl_Position - vec4(t, 0.0, 0.0);
EmitVertex();
finalColor = finalColor_geom[1];
t = edge_dir * (float(lineThickness) * (is_persp ? gl_in[1].gl_Position.w : 1.0));
gl_Position = gl_in[1].gl_Position + vec4(t, 0.0, 0.0);
EmitVertex();
gl_Position = gl_in[1].gl_Position - vec4(t, 0.0, 0.0);
EmitVertex();
EndPrimitive();
}