Showing posts with label Pixelation. Show all posts
Showing posts with label Pixelation. Show all posts

Monday, June 14, 2010

Pixelation Pixel Shader

Pixelation is process when pixel at x,y is duplicated into x+dx,y+dy rectangle. Pixelation GLSL fragment code:



uniform sampler2D tex;

void main()
{
float dx = 15.*(1./512.);
float dy = 10.*(1./512.);
vec2 coord = vec2(dx*floor(gl_TexCoord[0].x/dx),
dy*floor(gl_TexCoord[0].y/dy));
gl_FragColor = texture2D(tex, coord);
}



Smart

and pixelated version of it