Camera Shake Problem

In this https://playcanvas.com/editor/scene/1269143 demo project, i try to understand why does the camera shake when the lerp is close to 1. When lerp is 0.1 it`s ok. At first I thought it was caused by rigidbody objects in the scene, but even if I turn off the rigidbody feature of all boxes, the flickering still exists. When I lower the resolution settings from 1280*720 to 1/4, the flickering almost disappears. I think the problem is not in the simulation, it seems to be a render related issue. Do you have a idea for this?

I can confirm that this problem is also in the original project and has to do with the lerp settings in combination with the screen size. If you leave the ‘Lerp Amount’ on 0.1 there is no visible problem.

https://developer.playcanvas.com/en/tutorials/vehicle-physics/

image

Yes i know, i want try just more complex scene to see if camera shake happens with 0.1 lerp.There is camera shake with 0.1 lerp but not to much.If your scene is too complex you can see more camera shake.Why is this happening? In my demo project when you crash the cubes you can see there is no shake or flicker in movement.Is this a rendering problem because after i make resolution little i have less shake.

1 Like

Looking at the code:

        // Lerp the current camera position to where we want it to be
        // Note that the lerping is framerate independent
        this.currentPos.lerp(this.currentPos, this.targetPos, this.lerpAmount * dt * 60);

It’s possible that the lerp amount can be more than 1 if the framerate is less than 60 which will cause it to overshoot.

Changing it to be:

this.currentPos.lerp(this.currentPos, this.targetPos, 1 - Math.pow(1 - this.lerpAmount, dt));

Where this.lerpAmount is now 0.99 should make it work no matter the framerate. I’ve updated the original vehicle project.

1 Like