You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
math.smoothstep and math.smootherstep return a hard step when min is greater than max #9767
With min greater than max - a falling ramp - every x <= min returns 0 and every x > min returns 1. The result is an inverted hard step at min, not a ramp:
call
returns
a falling ramp would give
math.smoothstep(-0.3, -0.6, -0.2)
1
0
math.smoothstep(-0.3, -0.6, -0.45)
0
0.5
math.smoothstep(-0.3, -0.6, -0.7)
0
1
Reversed edges are a common idiom in shader code, where smoothstep(edge0, edge1, x) with edge0 > edge1 usually evaluates to the falling ramp, so the same expression moved between a shader and JavaScript changes meaning without any sign. Debug builds give no warning, and the docs describe the arguments as the lower and upper bound without saying what happens when they are the other way round.
Hit twice while building a game example: a terrain height falloff became a 110 m vertical drop within one grid quad, and a lighting fade became an on / off switch.
Activity
Fix math.smoothstep and smootherstep when min is greater than max (#9798