From 281cc0810df4f0b5dc642e5a9513b8f9a2237125 Mon Sep 17 00:00:00 2001 From: Louis Potok Date: Tue, 4 Feb 2025 13:02:36 -0500 Subject: [PATCH] fix: don't use undefined behavior of smoothstep The previous implementation calls smoothstep with edge0 < edge1. This is undefined behavior according to [the spec](https://registry.khronos.org/OpenGL-Refpages/gl4/html/smoothstep.xhtml) and the book's [glossary](https://github.com/patriciogonzalezvivo/thebookofshaders/blob/8fde956595fa90fe3cbb0239fc78c45aecb36d8f/glossary/smoothstep/README.md) This usage was introduced in PR #245 and closes #418. --- 05/linear.frag | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/05/linear.frag b/05/linear.frag index fb5a673d..89fe5b52 100644 --- a/05/linear.frag +++ b/05/linear.frag @@ -8,7 +8,7 @@ uniform float u_time; // Plot a line on Y using a value between 0.0-1.0 float plot(vec2 st) { - return smoothstep(0.02, 0.0, abs(st.y - st.x)); + return 1.0 - smoothstep(0.0, 0.02, abs(st.y - st.x)); } void main() {