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

Density function precision issues #42

Closed
jacobsjo opened this issue Dec 17, 2024 · 1 comment · Fixed by #44
Closed

Density function precision issues #42

jacobsjo opened this issue Dec 17, 2024 · 1 comment · Fixed by #44
Labels
bug Something isn't working /worldgen

Comments

@jacobsjo
Copy link
Contributor

Deepslate density functions aren't always accurate when floating point precision has an effect. I'll look into this more in the future.

Discord discussion: https://discord.com/channels/738046951236567162/750811307925831841/1318399656148860970

  • splines use float, we we should use Math.fround() to handle precision accurately
  • some casts to int are apparently wrong
@misode misode changed the title Density function preciession issues Density function precision issues Dec 17, 2024
@misode misode added the bug Something isn't working label Dec 17, 2024
@unnecessarymb
Copy link

https://discord.com/channels/738046951236567162/750811307925831841/1291393498658111629

At

return value - Math.floor(value / 3.3554432E7 + 0.5) * 3.3554432E7
, you use Math.floor. However, in the MC source code, a utility function is used that clamps the result to [-2^63+1, 2^63-1]. At very high firstOctave levels, this causes the ImprovedNoise calls to diverge, due to extreme precision loss in MC’s case. This divergence is of particular use to me, as it allows me to specify a cube/square/horizontal region at any offset using only two noise queries. I’m pinging here instead of writing a full issue because I’m not entirely sure to what degree a fix would be in scope, as that code hasn’t been touched in two years and this hasn’t come up before me, and I would welcome input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working /worldgen
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants