Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 05 non-standard use of smoothstep #418

Open
alextenb opened this issue Mar 29, 2024 · 0 comments
Open

Chapter 05 non-standard use of smoothstep #418

alextenb opened this issue Mar 29, 2024 · 0 comments

Comments

@alextenb
Copy link

alextenb commented Mar 29, 2024

Hi, the first code example in Chapter 05 contains a usage of smoothstep which should produce undefined output according to the OpenGL docs.

// 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));
}

It looks like, on my hardware, the result ends up being identical to:

float plot(vec2 st) {    
    return 1.0 - smoothstep(0.0, 0.02, abs(st.y - st.x));
}

But according to the OpenGL docs (and the documentation for the smoothstep function contained in the Book of Shaders) this function requires edge1 to be strictly greater than edge0. Being new to shaders, this confused me and I had to mess around with it to figure out what was actually happening.

@alextenb alextenb changed the title Chapter 05 undefined use of smoothstep Chapter 05 non-standard use of smoothstep Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant