Skip to content

Commit

Permalink
Standardizing on highp precision based on discussion in #2096
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisLoer committed May 12, 2017
1 parent b650d28 commit 767e3a8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
24 changes: 12 additions & 12 deletions src/shaders/symbol_icon.vertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ attribute vec4 a_data;
attribute vec3 a_size;
uniform bool u_is_size_zoom_constant;
uniform bool u_is_size_feature_constant;
uniform mediump float u_size_t; // used to interpolate between zoom stops when size is a composite function
uniform mediump float u_size; // used when size is both zoom and feature constant
uniform mediump float u_layout_size; // used when size is feature constant
uniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function
uniform highp float u_size; // used when size is both zoom and feature constant
uniform highp float u_layout_size; // used when size is feature constant
uniform highp float u_camera_to_center_distance;
uniform highp float u_pitch;
uniform highp float u_collision_y_stretch;
Expand All @@ -19,7 +19,7 @@ uniform highp float u_collision_y_stretch;
uniform mat4 u_matrix;

uniform bool u_is_text;
uniform mediump float u_zoom;
uniform highp float u_zoom;
uniform bool u_rotate_with_map;
uniform vec2 u_extrude_scale;

Expand All @@ -35,11 +35,11 @@ void main() {
vec2 a_offset = a_pos_offset.zw;

vec2 a_tex = a_data.xy;
mediump vec2 label_data = unpack_float(a_data[2]);
mediump float a_labelminzoom = label_data[0];
mediump vec2 a_zoom = unpack_float(a_data[3]);
mediump float a_minzoom = a_zoom[0];
mediump float a_maxzoom = a_zoom[1];
highp vec2 label_data = unpack_float(a_data[2]);
highp float a_labelminzoom = label_data[0];
highp vec2 a_zoom = unpack_float(a_data[3]);
highp float a_minzoom = a_zoom[0];
highp float a_maxzoom = a_zoom[1];

float size;
// In order to accommodate placing labels around corners in
Expand All @@ -50,7 +50,7 @@ void main() {
// currently rendered zoom level if text-size is zoom-dependent.
// Thus, we compensate for this difference by calculating an adjustment
// based on the scale of rendered text size relative to layout text size.
mediump float layoutSize;
highp float layoutSize;
if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {
size = mix(a_size[0], a_size[1], u_size_t) / 10.0;
layoutSize = a_size[2] / 10.0;
Expand All @@ -67,8 +67,8 @@ void main() {

float fontScale = u_is_text ? size / 24.0 : size;

mediump float zoomAdjust = log2(size / layoutSize);
mediump float adjustedZoom = (u_zoom - zoomAdjust) * 10.0;
highp float zoomAdjust = log2(size / layoutSize);
highp float adjustedZoom = (u_zoom - zoomAdjust) * 10.0;
// result: z = 0 if a_minzoom <= adjustedZoom < a_maxzoom, and 1 otherwise
highp float z = 2.0 - step(a_minzoom, adjustedZoom) - (1.0 - step(a_maxzoom, adjustedZoom));

Expand Down
26 changes: 13 additions & 13 deletions src/shaders/symbol_sdf.vertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ attribute vec4 a_data;
attribute vec3 a_size;
uniform bool u_is_size_zoom_constant;
uniform bool u_is_size_feature_constant;
uniform mediump float u_size_t; // used to interpolate between zoom stops when size is a composite function
uniform mediump float u_size; // used when size is both zoom and feature constant
uniform mediump float u_layout_size; // used when size is feature constant
uniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function
uniform highp float u_size; // used when size is both zoom and feature constant
uniform highp float u_layout_size; // used when size is feature constant

#pragma mapbox: define highp vec4 fill_color
#pragma mapbox: define highp vec4 halo_color
Expand All @@ -29,12 +29,12 @@ uniform mediump float u_layout_size; // used when size is feature constant
uniform mat4 u_matrix;

uniform bool u_is_text;
uniform mediump float u_zoom;
uniform highp float u_zoom;
uniform bool u_rotate_with_map;
uniform bool u_pitch_with_map;
uniform mediump float u_pitch;
uniform mediump float u_bearing;
uniform mediump float u_aspect_ratio;
uniform highp float u_pitch;
uniform highp float u_bearing;
uniform highp float u_aspect_ratio;
uniform highp float u_camera_to_center_distance;
uniform highp float u_collision_y_stretch;
uniform vec2 u_extrude_scale;
Expand Down Expand Up @@ -70,12 +70,12 @@ void main() {

vec2 a_tex = a_data.xy;

mediump vec2 label_data = unpack_float(a_data[2]);
mediump float a_labelminzoom = label_data[0];
mediump vec2 a_zoom = unpack_float(a_data[3]);
mediump float a_minzoom = a_zoom[0];
mediump float a_maxzoom = a_zoom[1];
highp vec2 label_data = unpack_float(a_data[2]);
highp float a_labelminzoom = label_data[0];
highp float a_lineangle = (label_data[1] / 256.0 * 2.0 * PI);
highp vec2 a_zoom = unpack_float(a_data[3]);
highp float a_minzoom = a_zoom[0];
highp float a_maxzoom = a_zoom[1];

// In order to accommodate placing labels around corners in
// symbol-placement: line, each glyph in a label could have multiple
Expand All @@ -85,7 +85,7 @@ void main() {
// currently rendered zoom level if text-size is zoom-dependent.
// Thus, we compensate for this difference by calculating an adjustment
// based on the scale of rendered text size relative to layout text size.
mediump float layoutSize;
highp float layoutSize;
if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {
v_size = mix(a_size[0], a_size[1], u_size_t) / 10.0;
layoutSize = a_size[2] / 10.0;
Expand Down

0 comments on commit 767e3a8

Please sign in to comment.