- Home /
Question by
TheCheese · Dec 05, 2012 at 04:52 AM ·
image-effects
How to fix flash with image effect when enabled?
Hi, I'm using the following code to combine two different images from different cameras. It works fine except for 1 frame when the image effect is enabled - there is a flash where the skytrainCam renders straight to the screen without blending. Can anyone suggest why this flash may be happening?
Thanks.
function OnRenderImage (source : RenderTexture, destination : RenderTexture) {
if (!camera.enabled || !isActive){
Graphics.Blit(source, destination);
return;
}
var skytrainRender : RenderTexture = RenderTexture.GetTemporary(source.width, source.height, 16);
var finalRender : RenderTexture = RenderTexture.GetTemporary(source.width, source.height, 16);
skytrainCam.enabled = false;
skytrainCam.targetTexture = skytrainRender;
skytrainCam.Render();
skytrainCam.targetTexture = null;
// apply skytrain layer as regular render
Graphics.Blit(skytrainRender, finalRender);
// apply regular camera layer at half alpha
Graphics.Blit(source, finalRender, combineMaterial);
// blit to destination to finish it off...
Graphics.Blit(finalRender, destination);
// release textures
RenderTexture.ReleaseTemporary (finalRender);
RenderTexture.ReleaseTemporary (skytrainRender);
}
Comment
Your answer
Follow this Question
Related Questions
Anti-Aliasing causes post processing effects to flip. 3 Answers
Screenshot with posteffects but without GUI 1 Answer
List error c# 1 Answer
Animated UI Image Sequence 1 Answer