Hi everyone
I want to use image effect (e.g. bloom) for only for the single of several Camera layers which contents GUI.
But as a result i have processed UILabels only:
Implementation:I use two cameras. First camera clears alpha to apply image effect to last layer only.
Wherein: If i did not apply clear alpha script for the first camera then i have image effect for the whole screenspace like this:
Second camera does image effect for own layer.
Scene hierarchy:- UIRoot
-- UICamera (layer 1) [clear alpha shader]
--- UIWidgets
--- ...
--- ...
-- UICamera (layer 2) [image effect script]
--- UIWidgets <- Here must be bloomed whole content of this layer but it works with UILabels only
--- ...
--- ...
Clear alpha shader is: Shader ""ClearAlpha"" {
SubShader {
ColorMask A
ZTest Always Cull Off ZWrite Off Fog { Mode Off }
Pass { Color (0,0,0,0) }
}
Fallback off
}
OnRenderImage method of the clear alpha script: void OnRenderImage (RenderTexture source, RenderTexture destination) {
Graphics.Blit (source, destination, material);
}
OnRenderImage method of the image effect script: void OnRenderImage (RenderTexture source, RenderTexture destination)
{
amount = Mathf.Sin (Time.fixedTime);
material.SetFloat("_Amount", amount);
Graphics.Blit (source, destination, material);
}