fix: NoiseEffectController producing zero progress on some platforms#3831
Merged
fix: NoiseEffectController producing zero progress on some platforms#3831
NoiseEffectController producing zero progress on some platforms#3831Conversation
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.
Description
NoiseEffectControllerwas sampling the noise function with a hardcoded y-coordinate of1:PerlinNoise(frequency: F)scales inputs internally byFbefore sampling, so the effective y becomes1 * F = F. With any integer frequency (e.g.frequency: 400), y lands on an integer row in the noise grid.When this happens,
yd0 = y - y0 = 0(fractional distance from the lower lattice row) and consequentlyys = 0(the quintic interpolation weight). Theys.lerp(bottomRow, topRow)call then collapses to justbottomRow, discarding all top-row gradient contributions.Within the surviving bottom row,
gradCoord2Dcomputesxd * g.x + yd * g.y. Sinceyd0 = 0, the y-gradient term vanishes entirely. Additionally, 2 of the 8 possible gradient vectors —(0,-1)and(0,1)— haveg.x = 0, so any corner the hash maps to those contributes nothing. The result is a severely reduced noise amplitude, sometimes collapsing to near-zero depending on the hash outcome for the seed and x-coordinate.Fixes:
1tosqrt2(≈ 1.41421356…). Sincesqrt2is irrational, no integerfrequencycan scale it to an integer row, soyd0 ≠ 0,ys ≠ 0, and all 4 corner gradients (both x and y components) always contribute fully.timer / durationtotimersofrequencycorrectly means oscillations per second regardless of effect duration. Previously, normalizing to0..1meant duration was silently controlling oscillation speed.Checklist
docsand added dartdoc comments with///.examplesordocs.Breaking Change?
Related Issues
Closes #3193