improved simplex noise#1690
Merged
Merged
Conversation
aykevl
reviewed
Aug 31, 2024
Contributor
aykevl
left a comment
There was a problem hiding this comment.
Change looks the same. Untested (not using FastLED at the moment) but it looks reasonable.
A few nitpicks below, feel free to ignore.
| // The result is scaled to return values in the interval [-1,1]. | ||
| int32_t n = n0 + n1 + n2; // .30 | ||
| n = (n << 6) / 46360; // fix scale to fit exactly in an int16_t | ||
| n = ((n >> 8) * 23163) >> 16; // fix scale to fit exactly in an int16 |
Contributor
There was a problem hiding this comment.
I guess you meant int16_t?
Suggested change
| n = ((n >> 8) * 23163) >> 16; // fix scale to fit exactly in an int16 | |
| n = ((n >> 8) * 23163) >> 16; // fix scale to fit exactly in an int16_t |
Same for 3D noise (which was also wrong in my original FastLED PR).
| // The result is scaled to stay just inside [-1,1] | ||
| int32_t n = n0 + n1 + n2 + n3; // .30 | ||
| n = (n << 6) / 64120; // fix scale to fit exactly in an int16 | ||
| n = ((n >> 8) * 16748) >> 16 ; // fix scale to fit exactly in an int16 |
Contributor
There was a problem hiding this comment.
Suggested change
| n = ((n >> 8) * 16748) >> 16 ; // fix scale to fit exactly in an int16 | |
| n = ((n >> 8) * 16748) >> 16; // fix scale to fit exactly in an int16_t |
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.
Optimizations lifted from https://github.com/aykevl