Performance of PostProcess with multiple materials

Hi,

I am currently working on a project where I need to do a lot of postprocessing. I implemented multiple effects, all in the same material, and enable/disable them via parameters and if-blocks.

This material looks terrible and is impossible to debug.

I though of putting each effect in a seperate material, and then only use the materials that are needed and swap them at runtime. Would this approach slow down my render? Or would it improve performance because of the if-blocks that are not needed any more?

Basically I have a few effects that (as of now) are performed one after the other:

  1. Move pixels via Look-up-tables
  2. Move the whole scene by an (x,y) offset
  3. Zoom in/out
  4. Apply color filters (black and white, grayscale, colorscale, threshold filter)
  5. Change contrast and brightness

It would not be difficult to move each of the steps into a seperate material.

Thanks.
Yes, all materials would sample postprocessinput, so I guess it is better to leave it in one material and seperate the blocks visually with comments.

If blocks in material always execute both sides.
For optimization you might want to use switches.

If you need to change post process in runtime, you can change the material on your post processing volume without noticeable performance hit.

The regression of having multiple post process blendable materials on a single post process volume is a cost of blending and the fact that most likely some of your materials will do the same work twice (eg. sampling postprocessinput or scene depth).