Skip to content

Commit

Permalink
make line-opacity work with line-image, fixes #970
Browse files Browse the repository at this point in the history
  • Loading branch information
ansis committed Jan 30, 2015
1 parent d5acbfb commit 0e9a86e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions js/render/draw_line.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ module.exports = function drawLine(painter, layer, posMatrix, tile) {
gl.uniform2fv(shader.u_pattern_tl, imagePos.tl);
gl.uniform2fv(shader.u_pattern_br, imagePos.br);
gl.uniform1f(shader.u_fade, fade);
gl.uniform1f(shader.u_opacity, layer.paint['line-opacity']);

} else {
shader = painter.lineShader;
Expand Down
2 changes: 1 addition & 1 deletion js/render/painter.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ GLPainter.prototype.setup = function() {

this.linepatternShader = gl.initializeShader('linepattern',
['a_pos', 'a_data'],
['u_matrix', 'u_exmatrix', 'u_linewidth', 'u_ratio', 'u_pattern_size', 'u_pattern_tl', 'u_pattern_br', 'u_point', 'u_blur', 'u_fade']);
['u_matrix', 'u_exmatrix', 'u_linewidth', 'u_ratio', 'u_pattern_size', 'u_pattern_tl', 'u_pattern_br', 'u_point', 'u_blur', 'u_fade', 'u_opacity']);

this.linesdfpatternShader = gl.initializeShader('linesdfpattern',
['a_pos', 'a_data'],
Expand Down
3 changes: 3 additions & 0 deletions shaders/linepattern.fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ uniform vec2 u_pattern_size;
uniform vec2 u_pattern_tl;
uniform vec2 u_pattern_br;
uniform float u_fade;
uniform float u_opacity;

uniform sampler2D u_image;

Expand All @@ -31,5 +32,7 @@ void main() {

vec4 color = texture2D(u_image, pos) * (1.0 - u_fade) + u_fade * texture2D(u_image, pos2);

alpha *= u_opacity;

gl_FragColor = color * alpha;
}

0 comments on commit 0e9a86e

Please sign in to comment.