Created
March 5, 2015 10:00
-
-
Save yiwenl/dbbaa48e1bc8efd3d89a to your computer and use it in GitHub Desktop.
GLSL random function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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