forked from mapbox/mapbox-gl-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fill_extrusion_pattern.fragment.glsl
51 lines (39 loc) · 1.51 KB
/
fill_extrusion_pattern.fragment.glsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
uniform vec2 u_texsize;
uniform float u_fade;
uniform sampler2D u_image;
varying vec2 v_pos_a;
varying vec2 v_pos_b;
varying vec4 v_lighting;
#pragma mapbox: define lowp float base
#pragma mapbox: define lowp float height
#pragma mapbox: define lowp vec4 pattern_from
#pragma mapbox: define lowp vec4 pattern_to
#pragma mapbox: define lowp float pixel_ratio_from
#pragma mapbox: define lowp float pixel_ratio_to
void main() {
#pragma mapbox: initialize lowp float base
#pragma mapbox: initialize lowp float height
#pragma mapbox: initialize mediump vec4 pattern_from
#pragma mapbox: initialize mediump vec4 pattern_to
#pragma mapbox: initialize lowp float pixel_ratio_from
#pragma mapbox: initialize lowp float pixel_ratio_to
vec2 pattern_tl_a = pattern_from.xy;
vec2 pattern_br_a = pattern_from.zw;
vec2 pattern_tl_b = pattern_to.xy;
vec2 pattern_br_b = pattern_to.zw;
vec2 imagecoord = mod(v_pos_a, 1.0);
vec2 pos = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, imagecoord);
vec4 color1 = texture2D(u_image, pos);
vec2 imagecoord_b = mod(v_pos_b, 1.0);
vec2 pos2 = mix(pattern_tl_b / u_texsize, pattern_br_b / u_texsize, imagecoord_b);
vec4 color2 = texture2D(u_image, pos2);
vec4 out_color = mix(color1, color2, u_fade);
out_color = out_color * v_lighting;
#ifdef FOG
out_color = fog_dither(fog_apply_premultiplied(out_color, v_fog_pos));
#endif
gl_FragColor = out_color;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor = vec4(1.0);
#endif
}