Last active
April 18, 2020 19:23
-
-
Save MarcoCiaramella/6a6f63be65918e9c52561ddd248f6a0d to your computer and use it in GitHub Desktop.
A fragment shader for glsl v1.0 that create a pixellation effect.
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
#version 100 | |
precision mediump float; | |
uniform sampler2D u_texId; | |
// render target width | |
uniform float u_rt_w; | |
// render target height | |
uniform float u_rt_h; | |
// width of a low resolution pixel | |
uniform float u_pixel_w; | |
// height of a low resolution pixel | |
uniform float u_pixel_h; | |
varying vec2 vTexCoords; | |
void main(){ | |
float dx = u_pixel_w*(1.0/u_rt_w); | |
float dy = u_pixel_h*(1.0/u_rt_h); | |
vec2 coord = vec2(dx*floor(vTexCoords.x/dx), dy*floor(vTexCoords.y/dy)); | |
vec3 tc = texture2D(u_texId, coord).rgb; | |
gl_FragColor = vec4(tc, 1.0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment