diff options
Diffstat (limited to 'src/mbgl/shaders/fill_extrusion_pattern.cpp')
-rw-r--r-- | src/mbgl/shaders/fill_extrusion_pattern.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/mbgl/shaders/fill_extrusion_pattern.cpp b/src/mbgl/shaders/fill_extrusion_pattern.cpp index d3e5eef1bf..466d0e04fe 100644 --- a/src/mbgl/shaders/fill_extrusion_pattern.cpp +++ b/src/mbgl/shaders/fill_extrusion_pattern.cpp @@ -22,8 +22,7 @@ uniform lowp vec3 u_lightpos; uniform lowp float u_lightintensity; attribute vec2 a_pos; -attribute vec3 a_normal; -attribute float a_edgedistance; +attribute vec4 a_normal_ed; varying vec2 v_pos_a; varying vec2 v_pos_b; @@ -65,26 +64,29 @@ void main() { #endif + vec3 normal = a_normal_ed.xyz; + float edgedistance = a_normal_ed.w; + base = max(0.0, base); height = max(0.0, height); - float t = mod(a_normal.x, 2.0); + float t = mod(normal.x, 2.0); float z = t > 0.0 ? height : base; gl_Position = u_matrix * vec4(a_pos, z, 1); - vec2 pos = a_normal.x == 1.0 && a_normal.y == 0.0 && a_normal.z == 16384.0 + vec2 pos = normal.x == 1.0 && normal.y == 0.0 && normal.z == 16384.0 ? a_pos // extrusion top - : vec2(a_edgedistance, z * u_height_factor); // extrusion side + : vec2(edgedistance, z * u_height_factor); // extrusion side 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, 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, pos); v_lighting = vec4(0.0, 0.0, 0.0, 1.0); - float directional = clamp(dot(a_normal / 16383.0, u_lightpos), 0.0, 1.0); + float directional = clamp(dot(normal / 16383.0, u_lightpos), 0.0, 1.0); directional = mix((1.0 - u_lightintensity), max((0.5 + u_lightintensity), 1.0), directional); - if (a_normal.y != 0.0) { + if (normal.y != 0.0) { directional *= clamp((t + base) * pow(height / 150.0, 0.5), mix(0.7, 0.98, 1.0 - u_lightintensity), 1.0); } |