diff options
author | Jere Tuliniemi <jere.tuliniemi@qt.io> | 2019-05-03 15:31:34 +0300 |
---|---|---|
committer | Jere Tuliniemi <jere.tuliniemi@qt.io> | 2019-05-06 11:15:27 +0000 |
commit | 655c1952563a31179fefb46eb178caa662bc3bee (patch) | |
tree | 6596fd66d209d65cf6e54777226425c3b83fb21b /src/Runtime/res | |
parent | e40d5ffa94622c316ff89bc4a0515c804cb2570e (diff) |
Implement fixes to the distance field renderer
- Change modelView matrix to mvp for sharper texts
- Support global opacity from parents
- Allow changing alpha from the text color picker
- Change shadow color to be the same as the text color
Task-number: QT3DS-3343
Task-number: QT3DS-3363
Change-Id: I37178abe6c9239619a3f9de440d2b9245a138a82
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'src/Runtime/res')
6 files changed, 6 insertions, 10 deletions
diff --git a/src/Runtime/res/effectlib/distancefieldtext.vert b/src/Runtime/res/effectlib/distancefieldtext.vert index a3feb378..01024c6b 100644 --- a/src/Runtime/res/effectlib/distancefieldtext.vert +++ b/src/Runtime/res/effectlib/distancefieldtext.vert @@ -1,5 +1,4 @@ uniform highp mat4 mvp; -uniform highp mat4 modelView; uniform highp float fontScale; uniform int textureWidth; uniform int textureHeight; @@ -59,7 +58,7 @@ highp float determinant(highp mat4 m) void main() { - highp float scale = fontScale * sqrt(abs(determinant(modelView))); + highp float scale = fontScale * sqrt(abs(determinant(mvp))); alphas = alphaRange(scale); sampleCoord = tCoord * vec2(1.0 / highp float(textureWidth), 1.0 / highp float(textureHeight)); gl_Position = mvp * vec4(vCoord, 1.0); diff --git a/src/Runtime/res/effectlib/distancefieldtext_core.vert b/src/Runtime/res/effectlib/distancefieldtext_core.vert index 1ced295c..ce6a165c 100644 --- a/src/Runtime/res/effectlib/distancefieldtext_core.vert +++ b/src/Runtime/res/effectlib/distancefieldtext_core.vert @@ -6,7 +6,6 @@ out vec2 sampleCoord; out vec2 alphas; uniform mat4 mvp; -uniform mat4 modelView; uniform int textureWidth; uniform int textureHeight; uniform float fontScale; @@ -37,7 +36,7 @@ vec2 alphaRange(float scale) void main() { - float scale = fontScale * sqrt(abs(determinant(modelView))); + float scale = fontScale * sqrt(abs(determinant(mvp))); alphas = alphaRange(scale); sampleCoord = tCoord * vec2(1.0 / float(textureWidth), 1.0 / float(textureHeight)); gl_Position = mvp * vec4(vCoord, 1.0); diff --git a/src/Runtime/res/effectlib/distancefieldtext_dropshadow.frag b/src/Runtime/res/effectlib/distancefieldtext_dropshadow.frag index da51c5c2..94b277cd 100644 --- a/src/Runtime/res/effectlib/distancefieldtext_dropshadow.frag +++ b/src/Runtime/res/effectlib/distancefieldtext_dropshadow.frag @@ -15,7 +15,7 @@ void main() clamp(shadowSampleCoord, normalizedTextureBounds.xy, normalizedTextureBounds.zw)).a); - highp vec4 shadowPixel = shadowColor * shadowAlpha; + highp vec4 shadowPixel = color * shadowColor * shadowAlpha; highp float textAlpha = smoothstep(alphas.x, alphas.y, diff --git a/src/Runtime/res/effectlib/distancefieldtext_dropshadow.vert b/src/Runtime/res/effectlib/distancefieldtext_dropshadow.vert index f645eb8c..f633aaa5 100644 --- a/src/Runtime/res/effectlib/distancefieldtext_dropshadow.vert +++ b/src/Runtime/res/effectlib/distancefieldtext_dropshadow.vert @@ -1,5 +1,4 @@ uniform highp mat4 mvp; -uniform highp mat4 modelView; uniform highp float fontScale; uniform int textureWidth; uniform int textureHeight; @@ -63,7 +62,7 @@ highp float determinant(highp mat4 m) void main() { - highp float scale = fontScale * sqrt(abs(determinant(modelView))); + highp float scale = fontScale * sqrt(abs(determinant(mvp))); alphas = alphaRange(scale); highp vec2 textureSizeMultiplier = vec2(1.0 / highp float(textureWidth), diff --git a/src/Runtime/res/effectlib/distancefieldtext_dropshadow_core.frag b/src/Runtime/res/effectlib/distancefieldtext_dropshadow_core.frag index 304b1874..4e46bd5f 100644 --- a/src/Runtime/res/effectlib/distancefieldtext_dropshadow_core.frag +++ b/src/Runtime/res/effectlib/distancefieldtext_dropshadow_core.frag @@ -18,7 +18,7 @@ void main() clamp(shadowSampleCoord, normalizedTextureBounds.xy, normalizedTextureBounds.zw)).r); - vec4 shadowPixel = shadowColor * shadowAlpha; + vec4 shadowPixel = color * shadowColor * shadowAlpha; float textAlpha = smoothstep(alphas.x, alphas.y, diff --git a/src/Runtime/res/effectlib/distancefieldtext_dropshadow_core.vert b/src/Runtime/res/effectlib/distancefieldtext_dropshadow_core.vert index 3b1ba712..9be245b8 100644 --- a/src/Runtime/res/effectlib/distancefieldtext_dropshadow_core.vert +++ b/src/Runtime/res/effectlib/distancefieldtext_dropshadow_core.vert @@ -9,7 +9,6 @@ out vec2 alphas; out vec4 normalizedTextureBounds; uniform mat4 mvp; -uniform mat4 modelView; uniform int textureWidth; uniform int textureHeight; uniform float fontScale; @@ -41,7 +40,7 @@ vec2 alphaRange(float scale) void main() { - float scale = fontScale * sqrt(abs(determinant(modelView))); + float scale = fontScale * sqrt(abs(determinant(mvp))); alphas = alphaRange(scale); vec2 textureSizeMultiplier = vec2(1.0 / float(textureWidth), 1.0 / float(textureHeight)); |