- Home /
Are multiple Unity Pro "Image Effects" auto-combined into a single (or as few as possible) quad shaders?
I'm new to Unity but have dabbled in shader-based ("modern") OpenGL with GLSL previously. (Don't really grok shaders written in HLSL or Cg at present, though.)
Let's say I want to apply to the final HDR linear render texture:
anti-aliasing (fxaa or other post technique, msaa is off globally)
glow or bloom or some such
tone-mapping
Vignette + chromatic aberration
gamma correction (since all prior RTT was in linear space for correct lighting calcs)
In GLSL, I would write a single fragment program ("pixel shader" in DX parlance) with 5 functions for those (or more for other effects) and in its main() would call the needed functions in the desired order.
In Unity, I can add those effects as Components to any Camera. Neat! But since I don't really grok the engine internals fully, right now I can't tell if Unity is smart enough to generate a single final pixel shader pass (or as few as strictly really necessary) for whatever effects combination is currently activated on the cam -- or worst case it has 5 individual post-fx shaders with each such pass processing the result of the previous post-fx shader pass.
So could anyone with more inside knowledge confirm how well Unity deals with this question?
Answer by byteprogramming · Aug 09, 2013 at 01:13 PM
These effects are written each for itself , there is no reason why Unity would try to be the smartass and change that. Each of the effects fetches pass and modifies it.
You could write your own post shader that combines them all.
$$anonymous$$eans the final output of multiple image effects depends also on the sequence how they are applied, right?
tomekkie --- by necessity, this must be the case one way or the other.
Thanks byteprogram$$anonymous$$g! That's pretty discomforting to know for anyone with some basic knowledge of GPUs. Program switching is known to be costly, and about some 5-9 of the various post-FX are just must-have "bare necessities" --- in a 1080p scenario, that's quite a few 5+$$anonymous$$B render textures and color buffers in VRA$$anonymous$$, also eating into bandwidth.
Looks like cloning the shaders into a custom combined post shader will be necessary then.