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?
Asked
Active
Viewed 5,732 times
2
-
4Possible duplicate of [Random / noise functions for GLSL](https://stackoverflow.com/questions/4200224/random-noise-functions-for-glsl) – Rabbid76 Nov 27 '18 at 19:08
-
Check this one out: https://www.shadertoy.com/view/4djSRW – Felipe Gutierrez Nov 28 '18 at 19:48
1 Answers
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

Darik Mohammed
- 11
- 1