Last active
March 4, 2016 19:39
-
-
Save kashimAstro/ef91aa4e88ea4f38ec4c to your computer and use it in GitHub Desktop.
Generated Noise pattern for dithering
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
vec2 rand(vec2 coord, vec2 uv, float noiseamount, bool noise) { | |
float noiseX = ((fract(1.0-coord.s*(uv.x/2.0))*0.25)+(fract(coord.t*(uv.y/2.0))*0.75))*2.0-1.0; | |
float noiseY = ((fract(1.0-coord.s*(uv.x/2.0))*0.75)+(fract(coord.t*(uv.y/2.0))*0.25))*2.0-1.0; | |
if (noise) { | |
noiseX = clamp(fract(sin(dot(coord ,vec2(12.9898,78.233))) * 43758.5453),0.0,1.0)*2.0-1.0; | |
noiseY = clamp(fract(sin(dot(coord ,vec2(12.9898,78.233)*2.0)) * 43758.5453),0.0,1.0)*2.0-1.0; | |
} | |
return vec2(noiseX,noiseY)*noiseamount; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment