Lag in cloned camera

Hi

I’m using 2 cameras on the same scene, then compositing the results to create a combined special effect I’m working on,

I’ve cloned the main camera, and updating its position in my render update method like so,



cam2.setLocation(cam.getLocation());

cam2.setDirection(cam.getDirection());

cam2.setRotation(cam.getRotation());



each camera is rendering into its own buffer, which i’m rendering back onto quads and layering, to achieve my desired effect,

however, there is a lag in the second camera being updated by the first camera, it’s kind of ‘swinging’ slightly behind it when i move/look around,



is there anyway to sync both cameras exactly - or much better ?

thanks.

Mhh…for rendering your off screen buffer , do you use a processor that create it’s own viewport or something like that?



This can cause the rendered buffer to be rendered one frame late, and give this lag impression on low frame rate.

I had the same issue with the water reflection



The solution is to create the viewport but not adding it to the rendermanager ( new ViewPort() instead of renderManager.createViewPort()). And handle the rendering of it yourself.



To do so in the preFrame of the porcessor call renderManager.renderViewPort(yourViewPort,tpf);

after that, don’t forget to restore the correct output in the renderManager (renderManager.getRenderer().setFrameBuffer(viewPort.getOutputFrameBuffer()):wink:



For more informations on this look at how it’s done in the WaterFilter in the preRender method (the last 3 lines).



hope that helps.

yes that’s exactly my problem, and also noticed it in the water reflection too,

thanks for the solution, will give it a try.