diff options
| author | Ray <raysan5@gmail.com> | 2019-05-17 01:17:40 +0200 |
|---|---|---|
| committer | Ray <raysan5@gmail.com> | 2019-05-17 01:17:40 +0200 |
| commit | 970f1e8ff15424ca2d96d89bf2871f0246835e9b (patch) | |
| tree | bc093a8eaee29739e52642c233d0f9102e9db7cf /examples/text/resources/shaders | |
| parent | ce87d2ced4dbe60f97d3ed48635231c222482b18 (diff) | |
| download | raylib-970f1e8ff15424ca2d96d89bf2871f0246835e9b.tar.gz raylib-970f1e8ff15424ca2d96d89bf2871f0246835e9b.zip | |
examples review
Diffstat (limited to 'examples/text/resources/shaders')
| -rw-r--r-- | examples/text/resources/shaders/glsl100/sdf.fs | 23 | ||||
| -rw-r--r-- | examples/text/resources/shaders/glsl330/sdf.fs (renamed from examples/text/resources/shaders/sdf.fs) | 0 |
2 files changed, 23 insertions, 0 deletions
diff --git a/examples/text/resources/shaders/glsl100/sdf.fs b/examples/text/resources/shaders/glsl100/sdf.fs new file mode 100644 index 00000000..b4214d92 --- /dev/null +++ b/examples/text/resources/shaders/glsl100/sdf.fs @@ -0,0 +1,23 @@ +#version 100 + +// Input vertex attributes (from vertex shader) +varying vec2 fragTexCoord; +varying vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +// 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 = texture2D(texture0, fragTexCoord).a; + float alpha = smoothstep(0.5 - smoothing, 0.5 + smoothing, distance); + + // Calculate final fragment color + gl_FragColor = vec4(fragColor.rgb, fragColor.a*alpha); +} diff --git a/examples/text/resources/shaders/sdf.fs b/examples/text/resources/shaders/glsl330/sdf.fs index 44d33e9b..44d33e9b 100644 --- a/examples/text/resources/shaders/sdf.fs +++ b/examples/text/resources/shaders/glsl330/sdf.fs |
