I need a random number generator to create some graphical static. I'm not looking for noise algorithms- I just want white noise. All I need for this is a random number generator in glsl. Specifically, I'll be using it to create a random lightness offset per-fragment, over time.
Requirements:
want to reiterate here- needs to function with only lowp floats. that one-liner going around the internet (fract(sin(dot(...)))) does not fulfill this condition! (at least, I assume the issue is with the lowp floats... could be really feeble sin implementation as well... so if you can avoid sin of high numbers too? bonus?)
This is the best I've been able to come up with, but I'm still not 100% satisfied (you can still see a small kaleidoscope-like effect if you look hard enough...
float rand(float frag_x, float frag_y, float t)
{
float r = t*7.924;
return fract(sin(frag_y+frag_x)*r+sin(frag_y-frag_x)*r*.7);
}
(the 7.924 and the .7 is me mashing on the keyboard- nothing more)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With