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

Commit

Permalink
separate u_opacity from u_color
Browse files Browse the repository at this point in the history
This prepares the shaders for the switch to data driven styling where
opacity and color need to be passed to the shader independent of
eachotehr.

remove the `additionalOpacity` parameter from `util.premultiply`
  • Loading branch information
ansis authored and Lucas Wojciechowski committed Apr 12, 2016
1 parent a09dee9 commit 0d34125
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion fill.fragment.glsl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
precision mediump float;

uniform lowp vec4 u_color;
uniform lowp float u_opacity;

void main() {
gl_FragColor = u_color;
gl_FragColor = u_color * u_opacity;
}
3 changes: 2 additions & 1 deletion line.fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ precision mediump float;

uniform vec2 u_linewidth;
uniform lowp vec4 u_color;
uniform lowp float u_opacity;
uniform float u_blur;

varying vec2 v_normal;
Expand All @@ -18,5 +19,5 @@ void main() {
float blur = u_blur * v_gamma_scale;
float alpha = clamp(min(dist - (u_linewidth.t - blur), u_linewidth.s - dist) / blur, 0.0, 1.0);

gl_FragColor = u_color * alpha;
gl_FragColor = u_color * (alpha * u_opacity);
}
3 changes: 2 additions & 1 deletion linesdfpattern.fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ precision mediump float;

uniform vec2 u_linewidth;
uniform lowp vec4 u_color;
uniform lowp float u_opacity;
uniform float u_blur;
uniform sampler2D u_image;
uniform float u_sdfgamma;
Expand All @@ -27,5 +28,5 @@ void main() {
float sdfdist = mix(sdfdist_a, sdfdist_b, u_mix);
alpha *= smoothstep(0.5 - u_sdfgamma, 0.5 + u_sdfgamma, sdfdist);

gl_FragColor = u_color * alpha;
gl_FragColor = u_color * (alpha * u_opacity);
}
3 changes: 2 additions & 1 deletion outline.fragment.glsl
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
precision mediump float;

uniform lowp vec4 u_color;
uniform lowp float u_opacity;

varying vec2 v_pos;

void main() {
float dist = length(v_pos - gl_FragCoord.xy);
float alpha = smoothstep(1.0, 0.0, dist);
gl_FragColor = u_color * alpha;
gl_FragColor = u_color * (alpha * u_opacity);
}
3 changes: 2 additions & 1 deletion sdf.fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ precision mediump float;
uniform sampler2D u_texture;
uniform sampler2D u_fadetexture;
uniform lowp vec4 u_color;
uniform lowp float u_opacity;
uniform lowp float u_buffer;
uniform lowp float u_gamma;

Expand All @@ -15,5 +16,5 @@ void main() {
lowp float fade_alpha = texture2D(u_fadetexture, v_fade_tex).a;
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;
gl_FragColor = u_color * (alpha * u_opacity);
}

0 comments on commit 0d34125

Please sign in to comment.