Improve the PRNG for the particles sample#549
Conversation
The trig / fract approach for PRNG is not portable and can produce remarkably non-random results on IMG GPUs. Replace this with a bit-xor & shift function, adapted from the cornell sample. Fixes the particles sample on Pixel 10.
|
Thank you! This has been on my list of things to look at for a bit but it's never been a high priority. For posterity, do you have a brief explanation as to why the previous approach wasn't portable? |
TL;DR: my theory is bad trig precision resulted in a terrible hash function. I haven't done any deep digging, but I would suspect it's about the precision of the trig functions. IIRC (it's been a while since my head has been in this space) the trig functions have quite a lot of leniency WRT the precision of their outputs, and I wouldn't be surprised if some GPUs used crude approximations (LUTs and the like) which scrape-by the API specification minimum thresholds. |
The trig / fract approach for PRNG is not portable and can produce remarkably non-random results on IMG GPUs.
Replace this with a bit-xor & shift function, adapted from the cornell sample.
Fixes the particles sample on Pixel 10.