Skip to content
This repository has been archived by the owner on Mar 23, 2019. It is now read-only.

Commit

Permalink
add an overdraw inspector
Browse files Browse the repository at this point in the history
The overdraw inspector shows how many time each fragment has been
shaded. White fragments were shaded 8 or more times. Black fragments
were shaded 0 times. Lower is better.

`map.showOverdrawInspector = true` turns it on.
  • Loading branch information
ansis committed Apr 26, 2016
1 parent 80614f9 commit 847b437
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 0 deletions.
4 changes: 4 additions & 0 deletions circle.fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ varying lowp float v_antialiasblur;
void main() {
float t = smoothstep(1.0 - max(u_blur, v_antialiasblur), 1.0, length(v_extrude));
gl_FragColor = v_color * (1.0 - t) * u_opacity;

#ifdef OVERDRAW_INSPECTOR
gl_FragColor = vec4(1.0);
#endif
}
4 changes: 4 additions & 0 deletions fill.fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ uniform lowp float u_opacity;

void main() {
gl_FragColor = u_color * u_opacity;

#ifdef OVERDRAW_INSPECTOR
gl_FragColor = vec4(1.0);
#endif
}
4 changes: 4 additions & 0 deletions icon.fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ varying vec2 v_fade_tex;
void main() {
lowp float alpha = texture2D(u_fadetexture, v_fade_tex).a * u_opacity;
gl_FragColor = texture2D(u_texture, v_tex) * alpha;

#ifdef OVERDRAW_INSPECTOR
gl_FragColor = vec4(1.0);
#endif
}
4 changes: 4 additions & 0 deletions line.fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ void main() {
float alpha = clamp(min(dist - (u_linewidth.t - blur), u_linewidth.s - dist) / blur, 0.0, 1.0);

gl_FragColor = u_color * (alpha * u_opacity);

#ifdef OVERDRAW_INSPECTOR
gl_FragColor = vec4(1.0);
#endif
}
4 changes: 4 additions & 0 deletions linepattern.fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ void main() {
alpha *= u_opacity;

gl_FragColor = color * alpha;

#ifdef OVERDRAW_INSPECTOR
gl_FragColor = vec4(1.0);
#endif
}
4 changes: 4 additions & 0 deletions linesdfpattern.fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ void main() {
alpha *= smoothstep(0.5 - u_sdfgamma, 0.5 + u_sdfgamma, sdfdist);

gl_FragColor = u_color * (alpha * u_opacity);

#ifdef OVERDRAW_INSPECTOR
gl_FragColor = vec4(1.0);
#endif
}
4 changes: 4 additions & 0 deletions outline.fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ void main() {
float dist = length(v_pos - gl_FragCoord.xy);
float alpha = smoothstep(1.0, 0.0, dist);
gl_FragColor = u_color * (alpha * u_opacity);

#ifdef OVERDRAW_INSPECTOR
gl_FragColor = vec4(1.0);
#endif
}
4 changes: 4 additions & 0 deletions outlinepattern.fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ void main() {


gl_FragColor = mix(color1, color2, u_mix) * alpha * u_opacity;

#ifdef OVERDRAW_INSPECTOR
gl_FragColor = vec4(1.0);
#endif
}
4 changes: 4 additions & 0 deletions pattern.fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ void main() {
vec4 color2 = texture2D(u_image, pos2);

gl_FragColor = mix(color1, color2, u_mix) * u_opacity;

#ifdef OVERDRAW_INSPECTOR
gl_FragColor = vec4(1.0);
#endif
}
4 changes: 4 additions & 0 deletions raster.fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,8 @@ void main() {
vec3 u_low_vec = vec3(u_brightness_high, u_brightness_high, u_brightness_high);

gl_FragColor = vec4(mix(u_high_vec, u_low_vec, rgb), color.a);

#ifdef OVERDRAW_INSPECTOR
gl_FragColor = vec4(1.0);
#endif
}
4 changes: 4 additions & 0 deletions sdf.fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ void main() {
lowp float gamma = u_gamma * v_gamma_scale;
lowp float alpha = smoothstep(u_buffer - gamma, u_buffer + gamma, dist) * fade_alpha;
gl_FragColor = u_color * (alpha * u_opacity);

#ifdef OVERDRAW_INSPECTOR
gl_FragColor = vec4(1.0);
#endif
}

0 comments on commit 847b437

Please sign in to comment.