2019-08-20 09:00:24 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
static const char* plotter_vs = R"(
|
|
|
|
in vec3 AttrPosition;
|
|
|
|
in vec4 AttrColor;
|
|
|
|
in vec2 AttrUV;
|
|
|
|
|
|
|
|
out vec4 Color;
|
|
|
|
out vec2 UV;
|
2019-12-15 05:12:38 +00:00
|
|
|
out vec2 Pos;
|
2019-08-20 09:00:24 +00:00
|
|
|
|
2019-08-22 16:43:54 +00:00
|
|
|
uniform mat4 projection;
|
2019-08-20 09:00:24 +00:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2019-12-15 23:17:41 +00:00
|
|
|
gl_Position = projection * vec4(AttrPosition, 1.0);
|
2019-08-20 09:00:24 +00:00
|
|
|
Color = AttrColor;
|
|
|
|
UV = AttrUV;
|
2019-12-15 05:12:38 +00:00
|
|
|
Pos = AttrPosition.xy;
|
2019-08-20 09:00:24 +00:00
|
|
|
}
|
|
|
|
)";
|
|
|
|
|
|
|
|
const char* plotter_ps = R"(
|
|
|
|
in vec4 Color;
|
|
|
|
in vec2 UV;
|
2019-12-15 05:12:38 +00:00
|
|
|
in vec2 Pos;
|
2019-08-20 09:00:24 +00:00
|
|
|
|
|
|
|
out vec4 FragColor;
|
|
|
|
|
2019-12-15 05:12:38 +00:00
|
|
|
uniform vec4 rendersettings;
|
|
|
|
|
2019-08-20 09:00:24 +00:00
|
|
|
void main()
|
|
|
|
{
|
2019-12-15 05:12:38 +00:00
|
|
|
if (UV.x < 0)
|
|
|
|
{
|
|
|
|
float yFrac = -(UV.x + 1);
|
|
|
|
|
|
|
|
vec2 tPos = vec2(
|
|
|
|
gl_FragCoord.x,
|
|
|
|
gl_FragCoord.y
|
|
|
|
);
|
|
|
|
|
|
|
|
// line stipple
|
2019-12-15 23:17:41 +00:00
|
|
|
if (mod(floor(mix(tPos.x, tPos.y, yFrac)), 2.0) > 0.0)
|
2019-12-15 05:12:38 +00:00
|
|
|
discard;
|
|
|
|
}
|
2019-08-20 09:00:24 +00:00
|
|
|
|
|
|
|
// line smoothing
|
2019-08-20 10:45:23 +00:00
|
|
|
float linewidth = 3.0;
|
|
|
|
float falloff = 1.8; //1.5..2.5
|
2019-08-20 09:00:24 +00:00
|
|
|
float centerdist = abs(UV.y);
|
|
|
|
float a = pow(clamp((linewidth - centerdist) / linewidth, 0.0, 1.0), falloff);
|
|
|
|
|
|
|
|
FragColor = vec4(Color.rgb, Color.a * a);
|
|
|
|
}
|
|
|
|
)";
|