Files
forge-steel/default/inc_rand.glsl
T

21 lines
411 B
GLSL

#ifndef INC_RAND
#define INC_RAND
// https://thebookofshaders.com/10/
// https://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/
float rand(float seed){
const float c = 43758.5453;
return fract(sin(seed) * c);
}
float rand(vec2 co)
{
const float a = 12.9898;
const float b = 78.233;
float dt= dot(co.xy ,vec2(a,b));
return rand(dt);
}
#endif