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

Add a random number generator intrinsic to HLSL #338

Open
AdamJMiles opened this issue Oct 11, 2024 · 1 comment
Open

Add a random number generator intrinsic to HLSL #338

AdamJMiles opened this issue Oct 11, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@AdamJMiles
Copy link
Member

Hi,

Shaders often call for the generation of random numbers. Sometimes that random number generation should form a well distributed 2D pattern (e.g. Blue noise or white noise) but other times it simply calls for generating a 32-bit random number used to make a random choice or as an index to load a random value.

Everyone writes their own function for this already (some better than others) and I believe it's something that would be worthy of being an intrinsic. A GPU may have its own source of random noise it could use to do this "more randomly" or faster than a generically written function that takes a seed. SDKs such as cuRAND exist to generate high quality random numbers of varying types and distributions.

I don't feel it necessary that the PRNGs be deterministic across vendors, but some guarantee of quality would be useful.

A uniform distribution RNG across a user-specified range would be the min-bar for what I'd hope to see supported, but other distributions such as normal would be useful to see too.

Thanks,

Adam

@AdamJMiles AdamJMiles added enhancement New feature or request needs-triage labels Oct 11, 2024
@devshgraphicsprogramming
Copy link

devshgraphicsprogramming commented Oct 12, 2024

For your enjoyment, Apache 2.0 licensed
https://github.com/Devsh-Graphics-Programming/Nabla/blob/master/include/nbl/builtin/hlsl/random/xoroshiro.hlsl

Good enough to raytrace on.

@damyanp damyanp added this to the Shader Model Backlog milestone Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Triaged
Development

No branches or pull requests

3 participants