2

I am trying to create a pseudo random float between 0.0 (inclusive) and 1.0 (inclusive) in GLSL ES in order to process the mutations for a chromosome on the GPU rather than a CPU in a genetic algorithm. How would I go about this?

Sammi3
  • 367
  • 2
  • 5
  • 16

1 Answers1

1
float random(vec2 st)
{
    return fract(sin(dot(st.xy, vec2(12.9898,78.233))) * 43758.5453123);
}

If you want to learn more about this function, here's a link from The Book of Shaders: https://thebookofshaders.com/10/

cigien
  • 57,834
  • 11
  • 73
  • 112