How to limit the color palette while rendering?

I’ve been looking for a way to limit the on screen colors to a certain color palette (like they had in old retro games).

Using the LUT alone does not work, since it does not effectively limited the number of colors on screen. So I’ve tried color quantization using a post processing material, the blueprint for it looks like this:

Sadly this causes rendering issues, namely, making parts of the screen flicker:
UE5Flickering

Please note that I’m using another post processing material in the gif, that lowers the rendering resolution, however, it does not cause the flickering, it just makes it more visible. The flickering persists, regardless of any other settings or actors in the scene.

If anybody has an idea how to either fix this flickering issue or what other technique could be used to archive a limited color palette, help would be much appreciated.

1 Like

Flickering may be due to temporal antialiasing. You might try disabling it and seeing if it goes away.

3 Likes

Thanks for your advice.
I’ve tried it out and while it does seem to affect the flickering a bit, it’s sadly not much more than a drop in the ocean. Any other idea what might be causing this?

Did you try FXAA?

My next guess would be that its caused by other features in the engine that rely on using temporal noise; I don’t know all of them but off the top of my head I think these ones do:

  • Lumen
  • Volumetric Fog
  • Volumetric Clouds
  • Sky Atmosphere system

Plus any material where you are using randomness in the DitherTemporalAA node.

I think your best course of action would be to disable Lumen (if you’re using it) and then set up a simple scene with just a couple of lights and see if you experience the same flickering effect. If it works okay then at the very least that will narrow it down to specific engine features.

2 Likes

I will definitely try FXXA.

I did try out all anti-aliasing methods (including FXAA).

I disabled Lumen here:
Lumen

No volumetric fog, no volumetric clouds, no sky atmosphere system:
Objects

Problem persists nontheless though:
UE5Flickering2

can you post your other post process materials?

Edit: Actually, try using floor or ceil instead of round nodes in your color quantization material

The only other post process material is the one I’ve mentioned in the starting post. And that one is unrelated to the problem.

Doesn’t matter if I’m using round, floor or ceil, the problem is either the same or worse (worse if I use ceil at the top path).

Maybe this is what you need.

Ever found a solution?

what fixed the flickering for me:

  1. Go to C:\Program Files\Epic Games\UE_[your UE version]\Engine\Shaders\Private
  2. Open PostProcessTonemap.usf in Notepad
  3. Add the line #undef USE_GRAIN_QUANTIZATION to the top of the file
    Also going into the project settings and changing the Anti-aliasing method to MSAA removed some more flickering
    still a bit left but much better after this
    Source: GitHub - DaveFace/UnrealRetroShaders: Retro PS1 Post Processing for Unreal Engine 4.
2 Likes

Using a post process effect is usually a good solution. Are you thinking something like this: Elias Wick | Gameboy and Elias Wick | Colorize?