diff options
Diffstat (limited to 'src/mbgl/shaders/fill_extrusion.cpp')
-rw-r--r-- | src/mbgl/shaders/fill_extrusion.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/mbgl/shaders/fill_extrusion.cpp b/src/mbgl/shaders/fill_extrusion.cpp index 9c5186fa06..1c96f3da36 100644 --- a/src/mbgl/shaders/fill_extrusion.cpp +++ b/src/mbgl/shaders/fill_extrusion.cpp @@ -8,7 +8,7 @@ namespace shaders { const char* fill_extrusion::name = "fill_extrusion"; const char* fill_extrusion::vertexSource = source() + 27816; -const char* fill_extrusion::fragmentSource = source() + 30616; +const char* fill_extrusion::fragmentSource = source() + 30918; // Uncompressed source of fill_extrusion.vertex.glsl: /* @@ -16,6 +16,7 @@ uniform mat4 u_matrix; uniform vec3 u_lightcolor; uniform lowp vec3 u_lightpos; uniform lowp float u_lightintensity; +uniform float u_vertical_gradient; attribute vec2 a_pos; attribute vec4 a_normal_ed; @@ -100,7 +101,11 @@ void main() { // Add gradient along z axis of side surfaces 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); + // This avoids another branching statement, but multiplies by a constant of 0.84 if no vertical gradient, + // and otherwise calculates the gradient based on base + height + directional *= ( + (1.0 - u_vertical_gradient) + + (u_vertical_gradient * clamp((t + base) * pow(height / 150.0, 0.5), mix(0.7, 0.98, 1.0 - u_lightintensity), 1.0))); } // Assign final color based on surface + ambient light color, diffuse light directional, and light color |