diff options
| author | Ray <[email protected]> | 2018-07-15 20:04:12 +0200 |
|---|---|---|
| committer | Ray <[email protected]> | 2018-07-15 20:04:12 +0200 |
| commit | dfc4baaa353d4aaa46068016f69dce44ad754ecb (patch) | |
| tree | 8abdd9608c70a08f1d0ddde7a73c690202e70c6b /examples/text/resources/shaders | |
| parent | 292499bdeb004e4b27752bd7814bf3a9b4ff835f (diff) | |
| download | raylib-dfc4baaa353d4aaa46068016f69dce44ad754ecb.tar.gz raylib-dfc4baaa353d4aaa46068016f69dce44ad754ecb.zip | |
Added new example: text_font_sdf
Diffstat (limited to 'examples/text/resources/shaders')
| -rw-r--r-- | examples/text/resources/shaders/sdf.fs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/examples/text/resources/shaders/sdf.fs b/examples/text/resources/shaders/sdf.fs new file mode 100644 index 00000000..44d33e9b --- /dev/null +++ b/examples/text/resources/shaders/sdf.fs @@ -0,0 +1,26 @@ +#version 330 + +// Input vertex attributes (from vertex shader) +in vec2 fragTexCoord; +in vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +// Output fragment color +out vec4 finalColor; + +// NOTE: Add here your custom variables +const float smoothing = 1.0/16.0; + +void main() +{ + // Texel color fetching from texture sampler + // NOTE: Calculate alpha using signed distance field (SDF) + float distance = texture(texture0, fragTexCoord).a; + float alpha = smoothstep(0.5 - smoothing, 0.5 + smoothing, distance); + + // Calculate final fragment color + finalColor = vec4(fragColor.rgb, fragColor.a*alpha); +} |
