diff options
Diffstat (limited to 'res/effectlib/distancefieldtext_dropshadow_core.frag')
-rw-r--r-- | res/effectlib/distancefieldtext_dropshadow_core.frag | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/res/effectlib/distancefieldtext_dropshadow_core.frag b/res/effectlib/distancefieldtext_dropshadow_core.frag new file mode 100644 index 0000000..e13182e --- /dev/null +++ b/res/effectlib/distancefieldtext_dropshadow_core.frag @@ -0,0 +1,28 @@ +in vec2 sampleCoord; +in vec2 shadowSampleCoord; +in vec4 normalizedTextureBounds; + +uniform sampler2D _qt_texture; +uniform vec4 color; +uniform vec4 shadowColor; + +void main() +{ + 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 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; + + fragOutput = mix(shadowPixel, textPixel, textPixel.a); +} |