- Home /
Unity 5 image effects for multiple cameras
Hello Everyone,
First, I apologize that this may seem like a repeat of other questions, but none of their solutions seems to work for me.
My issue is that I currently have 2 cameras in my game, one is the player's main camera, and the other is the layer camera that draws the player's arms.
My game uses edge detection image effects, but it will only work for one camera at a time. in this case, the layer camera, since it has a higher depth. So the hands get the edge detection, but the rest of the scene does not.
I used to have a script called Copy to Camera RT, and it worked great while I had Unity 4.6, but once I upgraded to Unity 5, it no longer works.
Would anyone know a way to fix this error?
Any help would be greatly appreciated. Thank you.
Hey, can you post the relevant parts of your script? And whatever error messages you are receiving.
there are no errors. Its just one camera is over-writing the image effects for the other camera. The scripts are the built in image effects for unity.
the copy to screen one is :
using System.Collections;
using UnityEngine;
// fixes the deferred lighting missing final copy&resolve, so the next camera gets the correctly final processed image in the temp screen RT as input
// NOTE: The script must be the last in the image effect chain, so order it in the inspector!
[ExecuteInEdit$$anonymous$$ode]
public class CopyToScreenRT : $$anonymous$$onoBehaviour
{
private RenderTexture activeRT; // hold the org. screen RT
private void OnPreRender()
{
if (camera.actualRenderingPath == RenderingPath.DeferredLighting) {
activeRT = RenderTexture.active;
}
else {
activeRT = null;
}
}
private void OnRenderImage(RenderTexture src, RenderTexture dest)
{
if (camera.actualRenderingPath == RenderingPath.DeferredLighting && activeRT) {
if (src.format == activeRT.format) {
Graphics.Blit(src, activeRT);
}
else {
Debug.LogWarning("Cant resolve texture, because of different formats!");
}
}
// script must be last anyway, so we don't need a final copy?
Graphics.Blit(src, dest); // just in case we are not last!
}
}
Still an ongoing issue.. Has anyone found a work around for this by chance?
Answer by Therian13 · Mar 27, 2015 at 01:09 AM
I got it to work finally.
I had to make my main camera's rendering path as Legacy Deffered, and the layer camera as Legacy Vertex Lit, and THEN I had to change the Quality Settings / Anti Aliasing to at least X2 Multi Sampling.
Why this worked, I'm not particularly sure. but the good news is, that it doesn't need any scripts to work anymore. so I guess there is that. :D
Changing the anti aliasing in quality settings did the trick for me, thank you
I really appreciate your answer, it stuck me for 1 day and finally I get this work :D