Screen Pixelation Effect
Notes on my implementation
For the last few days I was trying to figure out how to filter "high frequency" artifacts from my 3D models. I am now experimenting with pixelation post processing effect. The sampling function is below:
void SamplePixel_float(Texture2D Texture, float2 UV, SamplerState SS,
float OrthoSize, out float3 Color) {
// Calculate "how many" pixels will the final texture have
float2 finalRes = (_ScreenParams / PIXEL_SIZE) * OrthoSize;
// Discretize UVs
UV = floor(UV * finalRes) / finalRes;
// Sample texture
Color = SAMPLE_TEXTURE2D(Texture, SS, UV);
}
The custom function firstly calculates count of pixels in the final image. I multiply it by orthographic size to get the pixel size consistent when I zoom with my camera (I am not using perspective). Next I am calculating the UVs. It basically floors subpixel values to pixels. Finally I am sampling the texture.

On the picture above you can see connected node graph. I use camera's vertical orthographic size. Also note the Sampler State's
filter option set to Point
.

The result is not as bad as I thought it would be. The pixels are definitively jumping when I move the camera, but other than that it's quite alright looking for my initial test.
Last updated
Was this helpful?