forked from mapbox/mapbox-gl-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use separate shaders for drawing backgrounds and clipping masks
- Loading branch information
Lauren Budorick
authored
Jan 9, 2018
1 parent
3963d94
commit 5e44e62
Showing
10 changed files
with
93 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
uniform vec4 u_color; | ||
uniform float u_opacity; | ||
|
||
void main() { | ||
gl_FragColor = u_color * u_opacity; | ||
|
||
#ifdef OVERDRAW_INSPECTOR | ||
gl_FragColor = vec4(1.0); | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
attribute vec2 a_pos; | ||
|
||
uniform mat4 u_matrix; | ||
|
||
void main() { | ||
gl_Position = u_matrix * vec4(a_pos, 0, 1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
uniform vec2 u_pattern_tl_a; | ||
uniform vec2 u_pattern_br_a; | ||
uniform vec2 u_pattern_tl_b; | ||
uniform vec2 u_pattern_br_b; | ||
uniform vec2 u_texsize; | ||
uniform float u_mix; | ||
uniform float u_opacity; | ||
|
||
uniform sampler2D u_image; | ||
|
||
varying vec2 v_pos_a; | ||
varying vec2 v_pos_b; | ||
|
||
void main() { | ||
vec2 imagecoord = mod(v_pos_a, 1.0); | ||
vec2 pos = mix(u_pattern_tl_a / u_texsize, u_pattern_br_a / u_texsize, imagecoord); | ||
vec4 color1 = texture2D(u_image, pos); | ||
|
||
vec2 imagecoord_b = mod(v_pos_b, 1.0); | ||
vec2 pos2 = mix(u_pattern_tl_b / u_texsize, u_pattern_br_b / u_texsize, imagecoord_b); | ||
vec4 color2 = texture2D(u_image, pos2); | ||
|
||
gl_FragColor = mix(color1, color2, u_mix) * u_opacity; | ||
|
||
#ifdef OVERDRAW_INSPECTOR | ||
gl_FragColor = vec4(1.0); | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
uniform mat4 u_matrix; | ||
uniform vec2 u_pattern_size_a; | ||
uniform vec2 u_pattern_size_b; | ||
uniform vec2 u_pixel_coord_upper; | ||
uniform vec2 u_pixel_coord_lower; | ||
uniform float u_scale_a; | ||
uniform float u_scale_b; | ||
uniform float u_tile_units_to_pixels; | ||
|
||
attribute vec2 a_pos; | ||
|
||
varying vec2 v_pos_a; | ||
varying vec2 v_pos_b; | ||
|
||
void main() { | ||
gl_Position = u_matrix * vec4(a_pos, 0, 1); | ||
|
||
v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_a * u_pattern_size_a, u_tile_units_to_pixels, a_pos); | ||
v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_b * u_pattern_size_b, u_tile_units_to_pixels, a_pos); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
void main() { | ||
gl_FragColor = vec4(1.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
attribute vec2 a_pos; | ||
|
||
uniform mat4 u_matrix; | ||
|
||
void main() { | ||
gl_Position = u_matrix * vec4(a_pos, 0, 1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters