lundi 26 octobre 2015

What is a good algo for glsl lowp random number generation (for use in graphics)?

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:

  • generates number between 0.0 and 1.0 (don't care if inclusive/exclusive)
  • This needn't be that random. This won't be used for any security purposes, it just needs to be "random" to the naked eye.
  • It needs to be computable with lowp floats only! (for use on mobile)
  • Only has fragment_x, fragment_y, and time_mod_ten_pi as inputs (time_mod_ten_pi is exactly what it sounds like; the time (in seconds) since the game began, mod (10*3.1415) passed in as a float to allow for easy, continuous oscillations without worrying about precision issues. and 30 seconds is waaay more than enough time that a human won't notice repeating noise)
  • when displayed on a fragment_x * fragment_y grid, I don't want any visible patterns (statically, or in motion)
  • the simpler/faster, the better!

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?)




Aucun commentaire:

Enregistrer un commentaire