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

Use custom rand() #27

Open
krychu opened this issue Nov 11, 2022 · 3 comments
Open

Use custom rand() #27

krychu opened this issue Nov 11, 2022 · 3 comments

Comments

@krychu
Copy link
Owner

krychu commented Nov 11, 2022

This is an issue to find the best replacement for stdlib rand(). It'll be great to enjoy all the benefits but care needs to be taken to ensure good quality of the implementation as it directly impact the quality of generated images.

Rationale:

  • Better performance: speed and quality
  • Stability across platforms / different stdlibs
  • Don't alter rand() sequence in case the user app relies on it

Reference material

/cc @ggcrunchy, @ggsg-francis

@krychu
Copy link
Owner Author

krychu commented Nov 11, 2022

Notable info from the GDC talk:

What RNGs should we consider

Pasted Graphic 20

Pasted Graphic 21

Noise Hash functions

Pasted Graphic 23

Seeding Noise functions

Pasted Graphic 26

Pasted Graphic 27

@krychu
Copy link
Owner Author

krychu commented Nov 11, 2022

There were some issues with the squirrel function discovered, which led to an improved implementation:
https://twitter.com/squirreltweets/status/1421251894274625536?lang=en

The new implementation does involve two more noise numbers (5 instead of 3) and two more bit shifts (5 instead of 3). So the performance characteristics will change.

@krychu
Copy link
Owner Author

krychu commented Nov 11, 2022

Shortlist:

  • Squirrel 3
  • Squirrel 5
  • xors128
  • xorshift1
  • Marsaglia

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