Skip to content

Conversation

@anderoonies
Copy link
Contributor

Summary

At the boundaries of the pre-computed 2d gradient array the noise values produced would be far outside of 0->1, producing interesting bugs like this one:
badwater

The bug was caused by large dx and dy values being calculated and used in the dot products with the 4 gradient vectors.

In the case where x was 63, x0 would be 0 and dx would be x - x0 (63).
This is now resolved by making sure that dx and dy respect the boundary of PERLIN_NOISE_2D, that x1 and y1 (the bottom and right edges of the cell in the Perlin unit space) will properly wrap, and that the dot products are calculated using dy - 1 and dx - 1 rather than y - y1 etc to prevent these out of bounds issues.

@anderoonies anderoonies merged commit 5d3509b into codehs:main Jan 26, 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