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

Fix the range for Perlin noise (bad scale_factor) #283

Closed
wants to merge 5 commits into from

Conversation

bsurmanski
Copy link
Contributor

Builds off branch feature/1dperlin, since I added a test for 1d perlin too.

Each SCALE_FACTORs in the code seemed to be incorrect. Unscaled, each function would return between [-0.5, 0.5]. So in each dimension the scale factor should be the same: 2. I added unit tests to support this.

Each unscaled perlin noise function was off by a factor of 2. The
scale factors provided were all invalid.

Added tests to assert scale.
@bsurmanski bsurmanski changed the title Fix the scale value for Perlin noise Fix the range for Perlin noise (bad scale_factor) Jan 4, 2022
@bsurmanski
Copy link
Contributor Author

bsurmanski commented Jan 5, 2022

After further reading and consultation of the implementation of Perlin noise on p74-77 of Texturing and Modeling, a Procedural Approach, I believe the real issue is the 'gradient_dot_v' functions don't actually do a dot product. furthermore, the implementation used (assuming gradient_dot_v is implemented correctly) will skew the gradients towards the square diagonals and won't allow the gradients to be close to unit length away from the diagonals (since we are mapping a random vector on a square to a random vector on a circle with a fixed scale factor and not normalization).

I'm going to take another look for a way to do this. Ideally, the permutationtable would return a normalized vector as per Texturing and Modeling. Maybe a new permutation table type would be preferable.

@bsurmanski
Copy link
Contributor Author

Hmm, nevermind. I see now that you are using Perlin's Improved noise and the gradients are intentional.

@bsurmanski bsurmanski closed this Jan 6, 2022
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

Successfully merging this pull request may close these issues.

1 participant