summaryrefslogtreecommitdiffstats
path: root/src/runtime/shaders/distancefieldtext_dropshadow_core.frag
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime/shaders/distancefieldtext_dropshadow_core.frag')
-rw-r--r--src/runtime/shaders/distancefieldtext_dropshadow_core.frag26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/runtime/shaders/distancefieldtext_dropshadow_core.frag b/src/runtime/shaders/distancefieldtext_dropshadow_core.frag
index 8daa915..af7be60 100644
--- a/src/runtime/shaders/distancefieldtext_dropshadow_core.frag
+++ b/src/runtime/shaders/distancefieldtext_dropshadow_core.frag
@@ -10,24 +10,22 @@ uniform sampler2D _qt_texture;
uniform vec4 color;
uniform vec4 shadowColor;
-in vec2 alphas;
-
void main()
{
- float shadowAlpha = smoothstep(alphas.x,
- alphas.y,
- texture(_qt_texture,
- clamp(shadowSampleCoord,
- normalizedTextureBounds.xy,
- normalizedTextureBounds.zw)).r);
+ float shadowDistance = texture(_qt_texture,
+ clamp(shadowSampleCoord,
+ normalizedTextureBounds.xy,
+ normalizedTextureBounds.zw)).r;
+ float shadowDistanceD = fwidth(shadowDistance);
+ float shadowAlpha = smoothstep(0.5 - shadowDistanceD, 0.5, shadowDistance);
vec4 shadowPixel = color * shadowColor * shadowAlpha;
- float textAlpha = smoothstep(alphas.x,
- alphas.y,
- texture(_qt_texture,
- clamp(sampleCoord,
- normalizedTextureBounds.xy,
- normalizedTextureBounds.zw)).r);
+ float textDistance = texture(_qt_texture,
+ clamp(sampleCoord,
+ normalizedTextureBounds.xy,
+ normalizedTextureBounds.zw)).r;
+ float textDistanceD = fwidth(textDistance);
+ float textAlpha = smoothstep(0.5 - textDistanceD, 0.5, textDistance);
vec4 textPixel = color * textAlpha;
fragColor = mix(shadowPixel, textPixel, textPixel.a);