Avoiding PostProc desaturation with certain surface materials

Hi everyone!

Here is full text of my question on answerhub (Avoiding postproc desaturation in materials - Rendering - Unreal Engine Forums)

And I’ll just place it here once more:

If anyone saw Sin City movie - you guys certainly know, what do I mean while asking this question. I am having a partially desaturated scene, and it looks very cool, however I would like to, while needed, make certain materials show in full colors. For example, like in sin city, I would like something to be fully red. For one color it’s ok - I just made a custom blendable material, that takes things that are red and shows them red, while showing all the other things as partially desaturated. But this approach is not flexible enough for me, as ideally I would like to have ANY color avoid desaturation on scene, while needed… Is there any way to avoid scene desaturation, just like I can avoid depth buffering by simply setting a flag in the material settings?

Here is kind of the result i would like to have, aside from the fact that my scene is not fully desaturated, and I would like to have full control over which colors are getting desaturated, and which are not. If that’s even possible in current UE4’s pipeline.

If you’re not using it for anything else, there is always the custom depth buffer. It can be used to output depth only for selected objects. It is usually used for outlines, but you could use it to selectively avoid applying the desaturation effect.

This would work per static mesh. Ideally, it would be nice to output to a custom depth texture directly from your material on a per-pixel basis to get complete control over your desaturation effect, but I don’t know if that is possible.

You could also look into using a SceneCaptureComponent2D to render your scene into a texture using alternate materials that output the amount of saturation effect (into the red channel, for example). Then you access that texture in your post-processing effect. It could potentially be expensive to render the whole scene again, but you should be able to use a relatively low resolution render texture, and only render objects that need some type of custom saturation so it might not be too bad.

How do I output stuff into this custom depth buffer and from where?