- Home /
Manual camera render on fullscreen flicker/ghosting issue
My setup use various cameras. Most are automatically rendered on the usual Update Unity loop, but one of them is manually rendered using camera.Render() at a specific target framerate. I can switch from one camera to another and everything works fine in windowed mode.
However, when I try it in fullscreen, the manually rendered camera flickers. It is rendered as if the video double/triple buffer was rendered in a random order, or that the camera was rendering previous images in between my fixed framerate calls. I cannot provide a screenshot because each individual frame is fine, it is only the sequence of rendered frames which is corrupted.
Just to be sure, I removed the camera post effects like FXAA, but to no avail.
Maybe the problem comes from the way I "manually render". All cameras are disabled and I call camera.Render() in FixedUpdate() when I determine the timing is right to match the framerate I am targeting.
Does anyone have an idea? I don't know much about rendering, so maybe the trick is simple and obvious.
By the way, this happens on Windows 7, using various NVidia cards: GT220, GTX560Ti and GTX670.
Some more explanations and a workaround:
In fullscreen mode, the screen buffer is randomly filled with previous buffers when Unity feels like rendering between explicit camera.Render() calls. In windowed mode, the screen buffer is left untouched between render calls, which is the expected behaviour (expected by me at least!)
In the light of this, I used the following workaround:
1) The camera is set up to render to a texture:
screenRect = new Rect(0, 0, Screen.width, Screen.height);
cameraTexture = new RenderTexture(Screen.width, Screen.height, 24);
camera.targetTexture = cameraTexture;
2) I call camera.Render() in FixedUpdate() when I deter$$anonymous$$e the ti$$anonymous$$g is right.
3) In Update, I draw the texture rendered in 2):
Graphics.DrawTexture(screenRect, cameraTexture);
This workaround basically does not let the fullscreen mode play by itself. It explicitly draws several times the exact same buffer.
This works for me, but I am still interested in hearing why the fullscreen mode does that.