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

Mistake in smoothstep description: "undefined if edge0 ≥ edge1" #363

Open
singalen opened this issue Dec 27, 2021 · 2 comments
Open

Mistake in smoothstep description: "undefined if edge0 ≥ edge1" #363

singalen opened this issue Dec 27, 2021 · 2 comments

Comments

@singalen
Copy link

https://thebookofshaders.com/glossary/?search=smoothstep says "Results are undefined if edge0 ≥ edge1".

At the same time, https://thebookofshaders.com/05/ uses smoothstep(0.02, 0.0, ...).

NVidia reference says:

  • Returns 0 if x < a < b or x > a > b
  • Returns 1 if x < b < a or x > b > a

which actually explains why and how the code works.

@mogita
Copy link

mogita commented May 14, 2023

It'd be helpful to add a note after the definition about how GLSL actually implements smoothstep in a way that reverse the output to [1, 0] when the left side is greater than the right side. I looked at the code and tried to understand how it actually worked but apparently not complying with what the definition said.

@stonerfish
Copy link

The GLSL spec does say "Results are undefined if edge0 >= edge1."
The lesson learned in this section is the specs do not define what is actually implemented. It took me a bit for that to sink in.

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

3 participants