[core] fix font rendering at the top edge of the viewport
This commit is contained in:
@@ -49,18 +49,11 @@ void Painter::renderSDF(SymbolBucket &bucket,
|
||||
float fontScale = fontSize / sdfFontSize;
|
||||
matrix::scale(exMatrix, exMatrix, fontScale, fontScale, 1.0f);
|
||||
|
||||
// calculate how much longer the real world distance is at the top of the screen
|
||||
// than at the middle of the screen.
|
||||
float topedgelength = std::sqrt(std::pow(state.getHeight(), 2) / 4.0f * (1.0f + std::pow(state.getAltitude(), 2)));
|
||||
float x = state.getHeight() / 2.0f * std::tan(state.getPitch());
|
||||
float extra = (topedgelength + x) / topedgelength - 1;
|
||||
|
||||
config.program = sdfShader.program;
|
||||
sdfShader.u_matrix = vtxMatrix;
|
||||
sdfShader.u_exmatrix = exMatrix;
|
||||
sdfShader.u_texsize = texsize;
|
||||
sdfShader.u_skewed = skewed;
|
||||
sdfShader.u_extra = extra;
|
||||
|
||||
// adjust min/max zooms for variable font sies
|
||||
float zoomAdjust = std::log(fontSize / bucketProperties.size) / std::log(2);
|
||||
|
||||
@@ -14,7 +14,6 @@ uniform float u_minfadezoom;
|
||||
uniform float u_maxfadezoom;
|
||||
uniform float u_fadezoom;
|
||||
uniform bool u_skewed;
|
||||
uniform float u_extra;
|
||||
|
||||
uniform vec2 u_texsize;
|
||||
|
||||
@@ -59,11 +58,7 @@ void main() {
|
||||
gl_Position = u_matrix * vec4(a_pos, 0, 1) + extrude;
|
||||
}
|
||||
|
||||
// position of y on the screen
|
||||
float y = gl_Position.y / gl_Position.w;
|
||||
// how much features are squished in all directions by the perspectiveness
|
||||
float perspective_scale = 1.0 / (1.0 - y * u_extra);
|
||||
v_gamma_scale = perspective_scale;
|
||||
v_gamma_scale = (gl_Position.w - 0.5);
|
||||
|
||||
v_tex = a_tex / u_texsize;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ public:
|
||||
Uniform<GLfloat> u_maxfadezoom = {"u_maxfadezoom", *this};
|
||||
Uniform<GLfloat> u_fadezoom = {"u_fadezoom", *this};
|
||||
Uniform<GLint> u_skewed = {"u_skewed", *this};
|
||||
Uniform<GLfloat> u_extra = {"u_extra", *this};
|
||||
|
||||
protected:
|
||||
GLint a_offset = -1;
|
||||
|
||||
Reference in New Issue
Block a user