Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rewrite push_line interface, and make patterned lines match gecko closer #1923

Merged
merged 4 commits into from Oct 25, 2017
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Make dot and dash line shaders more precise

The number-of-pieces approach the old implementation had lead to too much
accumulated rounding error, causing periodic truncated dashes. This
lead to lines falling out of their periodic pattern, breaking the clipping
tricks gecko applies downstream.
  • Loading branch information
Gankra committed Oct 24, 2017
commit 9bf89c73300b21e0dbd630421e5f2e3773ded9b0
@@ -59,30 +59,22 @@ void main(void) {
break;
}
case LINE_STYLE_DASHED: {
// y = dash on + off length
// z = dash length
// w = center line of edge cross-axis (for dots only)
float desired_dash_length = size.y * 3.0;
// Consider half total length since there is an equal on/off for each dash.
float dash_count = 1.0 + ceil(size.x / desired_dash_length);
float dash_length = size.x / dash_count;
vParams = vec4(2.0 * dash_length,
dash_length,
float dash_length = size.y * 3.0;
vParams = vec4(2.0 * dash_length, // period
dash_length, // dash length
0.0,
0.0);
break;
}
case LINE_STYLE_DOTTED: {
float diameter = size.y;
float radius = 0.5 * diameter;
float dot_count = ceil(0.5 * size.x / diameter);
float empty_space = size.x - dot_count * diameter;
float distance_between_centers = diameter + empty_space / dot_count;
float period = diameter * 2.0;
float center_line = pos.y + 0.5 * size.y;
vParams = vec4(distance_between_centers,
radius,
float max_x = floor(size.x / period) * period;
vParams = vec4(period,
diameter / 2.0, // radius
center_line,
0.0);
max_x);
break;
}
case LINE_STYLE_WAVY: {
@@ -223,6 +215,8 @@ void main(void) {
vec2 dot_relative_pos = vec2(x, pos.y) - vParams.yz;
float dot_distance = length(dot_relative_pos) - vParams.y;
alpha = min(alpha, distance_aa(aa_range, dot_distance));
// Clip off partial dots
alpha *= step(pos.x - vLocalOrigin.x, vParams.w);
break;
}
case LINE_STYLE_WAVY: {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.