Skip to content

Instantly share code, notes, and snippets.

@kashimAstro
Last active March 4, 2016 19:39
Show Gist options
  • Save kashimAstro/ef91aa4e88ea4f38ec4c to your computer and use it in GitHub Desktop.
Save kashimAstro/ef91aa4e88ea4f38ec4c to your computer and use it in GitHub Desktop.
Generated Noise pattern for dithering
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