From 52ae69555c8846b3034bb5435518569eab908205 Mon Sep 17 00:00:00 2001 From: Job Date: Tue, 30 May 2023 14:52:46 +0200 Subject: [PATCH] Clarified GLSL example --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e4c717e..b52ea22 100644 --- a/README.md +++ b/README.md @@ -32,12 +32,14 @@ vec4 pixel = texture(source, uv); vec4 color = vec4(pixel.rgb, step(0.5, pixel.a); ``` -This example sets opacity to either `0` or `1`. Edges can also be anti aliased using the following GLSL snippet: +This example sets alpha to either `0` or `1`. Edges can also be anti aliased using the following GLSL snippet: ``` glsl const float epsilon = 0.000001; vec4 pixel = texture(source, uv); -float alpha = clamp((pixel.a - .5) / max(fwidth(pixel.a) * .5, epsilon), 0., 1.); +float alpha = clamp((pixel.a - 0.5) / max(fwidth(pixel.a) * 0.5, epsilon), 0.0, 1.0); vec4 color = vec4(pixel.rgb, alpha); -``` \ No newline at end of file +``` + +This example interpolates alpha from `0` to `1`, creating smooth anti aliased edges. \ No newline at end of file