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

Replicate Starbound's tile randomness #1

Open
blixt opened this issue Aug 26, 2016 · 0 comments
Open

Replicate Starbound's tile randomness #1

blixt opened this issue Aug 26, 2016 · 0 comments

Comments

@blixt
Copy link
Owner

blixt commented Aug 26, 2016

Every tile material has several variants to look less repetitive. These variants are chosen based on a pseudorandom pattern that follows a certain set of rules (so the tiles don't change every time they're rendered).

The pattern would most likely consist of the following parameters:

  • A constant seed for foreground tiles and another for background tiles (possibly also ones for material mods)
  • The world seed (so every world has a different pattern)
  • The X, Y coordinates

Additionally, depending on the hashing function, it may also consist of:

  • An initial hash value
  • A prime number to multiply with

Based on research and digging through Starbound's binary files, I've found the following:

  • At some point Starbound used FNV hashing but possibly not anymore (several FNV constants are not in the binary)
  • The Starbound binary does contain the full set of primes used by xxHash
  • Additionally, the binary contains at least the following primes:
    • 16,777,619 (associated with 32-bit FNV)
    • 1,099,511,628,211 (associated with 64-bit FNV)
    • 2,938,728,349 (appears to be unique to Starbound)
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

No branches or pull requests

1 participant