Bug fix: smoothstep should emulate glsl behavior in degenerate cases#2915
Open
bhouston wants to merge 2 commits into
Open
Bug fix: smoothstep should emulate glsl behavior in degenerate cases#2915bhouston wants to merge 2 commits into
bhouston wants to merge 2 commits into
Conversation
Apply the inverted/degenerate smoothstep fallback component-wise for vector2, vector3, and vector4 to match the float fix across all smoothstep nodedef variants.
Member
|
See #2914 (comment) for recommendations on resolving this category of undefined behaviors through new specification proposals, so that our per-language implementations have an unambiguous reference to match. |
Contributor
|
fwiw, there is already a doc change proposal for this, but old by now: AcademySoftwareFoundation/OpenShadingLanguage#1851 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Like most of my PRs I noticed via https://material-fidelity.ben3d.ca that smooth step when the bounds are inverted does not replicate glsl behaviour. This PR fixes that.
Summary
Update the float
smoothstepimplementation ingenoslto handle degenerate/inverted bounds explicitly.ND_smoothstep_floatnow uses:smoothstep(low, high, in)whenhigh > lowhigh <= low: hard step athigh(in < high ? 0.0 : 1.0)Why
For inverted bounds,
smoothstepbehavior can diverge across backends due to undefined/implementation-dependent handling. This caused visible mismatch inmaterialx-oslfor degenerate node tests.Making the fallback explicit in
genoslimproves determinism and cross-renderer consistency for these edge cases.Validation
Renders from OSL, Metal and GLSL now match: