I’m trying to write a “Retro Filter” image effect.
Basically I have two steps for now.
- Make the image pixelated
- Reduce the amount of different colors in the image
For step 2 I’m using a simple shader I wrote that shrinks down the amount of possible colors But step 1 doesn’t work. You know how a picture gets very pixelated and “blocky” when you scale it down and up again in an image editing program (Photoshop, Gimp, Paint, etc.)?
That’s exactly what I was looking for. So, I decided to scale the Image down and up again in OnRenderImage. The code for that looks like this:
RenderTexture scaleBuffer = RenderTexture.GetTemporary(source.width / DownscaleFactor, source.height / DownscaleFactor);
accumTexture.MarkRestoreExpected();
Graphics.Blit(accumTexture, scaleBuffer);
Graphics.Blit(scaleBuffer, accumTexture);
RenderTexture.ReleaseTemporary(scaleBuffer);
I assumed that would exactly do what I want. But instead of feeling blocky, it looks very washed out. Here you can see it with DownscaleFactor set to 8:
Result with factor 8
"Ok, that looks a bit washed out but it surely will get better if I scale it down even more and then back up again! At least that’s what i was thinking. But this is what happens when I set DownscaleFactor to 32: Result with factor 32
I have no Idea why this is happening. I tried turning AA off everywhere I could, including setting the AA level of the RenderTexture objects to 1.
I’d be ever so grateful if someone could tell me why this is happening, what I can do about it or what else would work to get the picture all blocky. I’m sure a shader might work but the shader I wrote for reducing the colors was my first shader ever and I’m just about to learn the basics. I have no idea how to go about writing a “pixeling” shader and the down- and upscale approach felt very intuitive to me.
Thank you very much for your help!