diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2019-02-21 15:19:53 +0100 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2019-02-22 06:44:00 +0000 |
commit | a1778a537e7340598d7aab613e6258059d269e4f (patch) | |
tree | 4a72942b5fc638f177b2c17cb016716edc9c95cd | |
parent | 7e60b8df4e2c7e97e7ebb97974d7a0481c89b0a6 (diff) |
Fix distance field shader on GLES
The shaders were completely missing precision qualifiers.
Task-number: QT3DS-3085
Change-Id: I8c05ba3ac5c5f0b82d212e9c42b356c8fd1b7ba2
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r-- | src/runtime/shaders/distancefieldtext.frag | 6 | ||||
-rw-r--r-- | src/runtime/shaders/distancefieldtext.vert | 52 |
2 files changed, 29 insertions, 29 deletions
diff --git a/src/runtime/shaders/distancefieldtext.frag b/src/runtime/shaders/distancefieldtext.frag index 2c072bf..efcf89e 100644 --- a/src/runtime/shaders/distancefieldtext.frag +++ b/src/runtime/shaders/distancefieldtext.frag @@ -1,8 +1,8 @@ -varying vec2 sampleCoord; -varying vec2 alphas; +varying highp vec2 sampleCoord; +varying highp vec2 alphas; uniform sampler2D _qt_texture; -uniform vec4 color; +uniform highp vec4 color; void main() { diff --git a/src/runtime/shaders/distancefieldtext.vert b/src/runtime/shaders/distancefieldtext.vert index 50966cf..879545f 100644 --- a/src/runtime/shaders/distancefieldtext.vert +++ b/src/runtime/shaders/distancefieldtext.vert @@ -1,54 +1,54 @@ -uniform mat4 mvp; -uniform mat4 modelView; -uniform float fontScale; +uniform highp mat4 mvp; +uniform highp mat4 modelView; +uniform highp float fontScale; uniform int textureWidth; uniform int textureHeight; -attribute vec4 vCoord; -attribute vec2 tCoord; +attribute highp vec4 vCoord; +attribute highp vec2 tCoord; -varying vec2 sampleCoord; -varying vec2 alphas; +varying highp vec2 sampleCoord; +varying highp vec2 alphas; -float thresholdFunc(float scale) +highp float thresholdFunc(highp float scale) { - float base = 0.5; - float baseDev = 0.065; - float devScaleMin = 0.15; - float devScaleMax = 0.3; + highp float base = 0.5; + highp float baseDev = 0.065; + highp float devScaleMin = 0.15; + highp float devScaleMax = 0.3; return base - ((clamp(scale, devScaleMin, devScaleMax) - devScaleMin) / (devScaleMax - devScaleMin) * -baseDev + baseDev); } -float spreadFunc(float scale) +highp float spreadFunc(highp float scale) { return 0.06 / scale; } -vec2 alphaRange(float scale) +highp vec2 alphaRange(highp float scale) { - float base = thresholdFunc(scale); - float range = spreadFunc(scale); - float alphaMin = max(0.0, base - range); - float alphaMax = min(base + range, 1.0); - return vec2(alphaMin, alphaMax); + highp float base = thresholdFunc(scale); + highp float range = spreadFunc(scale); + highp float alphaMin = max(0.0, base - range); + highp float alphaMax = min(base + range, 1.0); + return highp vec2(alphaMin, alphaMax); } -float determinantOfSubmatrix(mat4 m, int col0, int col1, int row0, int row1) +highp float determinantOfSubmatrix(highp mat4 m, int col0, int col1, int row0, int row1) { return m[col0][row0] * m[col1][row1] - m[col0][row1] * m[col1][row0]; } -float determinantOfSubmatrix(mat4 m, int col0, int col1, int col2, int row0, int row1, int row2) +highp float determinantOfSubmatrix(highp mat4 m, int col0, int col1, int col2, int row0, int row1, int row2) { - float det = m[col0][row0] * determinantOfSubmatrix(m, col1, col2, row1, row2); + highp float det = m[col0][row0] * determinantOfSubmatrix(m, col1, col2, row1, row2); det -= m[col1][row0] * determinantOfSubmatrix(m, col0, col2, row1, row2); det += m[col2][row0] * determinantOfSubmatrix(m, col0, col1, row1, row2); return det; } -float determinant(mat4 m) +highp float determinant(highp mat4 m) { - float det = m[0][0] * determinantOfSubmatrix(m, 1, 2, 3, 1, 2, 3); + highp float det = m[0][0] * determinantOfSubmatrix(m, 1, 2, 3, 1, 2, 3); det -= m[1][0] * determinantOfSubmatrix(m, 0, 2, 3, 1, 2, 3); det += m[2][0] * determinantOfSubmatrix(m, 0, 1, 3, 1, 2, 3); det -= m[3][0] * determinantOfSubmatrix(m, 0, 1, 2, 1, 2, 3); @@ -57,8 +57,8 @@ float determinant(mat4 m) void main() { - float scale = fontScale * sqrt(abs(determinant(modelView))); + highp float scale = fontScale * sqrt(abs(determinant(modelView))); alphas = alphaRange(scale); - sampleCoord = tCoord * vec2(1.0 / float(textureWidth), 1.0 / float(textureHeight)); + sampleCoord = tCoord * highp vec2(1.0 / highp float(textureWidth), 1.0 / highp float(textureHeight)); gl_Position = mvp * vCoord; } |