Skip to content

Instantly share code, notes, and snippets.

@yiwenl
Created March 5, 2015 10:00
Show Gist options
  • Save yiwenl/dbbaa48e1bc8efd3d89a to your computer and use it in GitHub Desktop.
Save yiwenl/dbbaa48e1bc8efd3d89a to your computer and use it in GitHub Desktop.
GLSL random function
// From glfx.js : https://github.com/evanw/glfx.js
float random(vec3 scale, float seed) {
/* use the fragment position for a different seed per-pixel */
return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);
}
float rand(vec2 co){
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment