Last active
July 18, 2018 00:45
-
-
Save ykob/08f335981f2f95dcf8d8d525a9a9e7b6 to your computer and use it in GitHub Desktop.
fragment shader of mosaic filter
This file contains 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
uniform vec2 resolution; | |
uniform sampler2D texture; | |
varying vec2 vUv; | |
const float mosaic = 12.0; | |
void main() { | |
vec4 color = vec4(0.0); | |
vec2 offset = vec2(mod(gl_FragCoord.x, mosaic), mod(gl_FragCoord.y, mosaic)); | |
for (float x = 0.0; x < mosaic; x++){ | |
for (float y = 0.0; y < mosaic; y++){ | |
color += texture2D(texture, vUv - (offset + vec2(x, y)) / resolution); | |
} | |
} | |
gl_FragColor = color / pow(mosaic, 2.0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment