Typical methods to transition from one camera to another camera is to leverage pre-defined blend curves and a specified blend time to control the speed and smoothness of blending. However, one problem with curves is that they don't provide velocity continuity at the start and end of transition, which usually results in a visual artifact either a sudden stop or a sudden launch. Fortunately, inertialization provides such continuity. In this blog post, I will attemp to introduce inertialization into camera transition, uncovering its potential for a very smooth and nice camera transition process.
Inertialization in Animation
Inertialization is an important technique used in animation to eliminate tne evaluation cost for the source animation and maintain a smooth transition feeling.
What inertialization does is to employ a fifth-order polynimial
The update expression at each timestamp is:
where
To ensure the continuity at transition start and transition end,
For (1), we have:
For (2)~(6), we can derive:
where
For vector type, inertialization is not directly applied to each of the vector components independently. Rather, it's applied to the magnitude of the vector and keep the direction fixed.
More concretely, given a source vector
For rotation type, inertialization is applied to the angle of the
axis-angle decomposition of rotations. The difference rotation for
current frame is
What Do We Want for Camera?
If we see camera as a special type of joint, we can seamlessly apply inertialization to the camera transition. Before we introduce how we actually implement inertialized camera transition, we must keep in mind what we really want for camera transition.
- Maintain velocity and (possibly) acceleration continuity when transiton starts and ends. Different from animation, camera serves as the eye through which the players see the game world, and thus it is very sensitive to discontinuous positional and rotational jitters. In many cases such as transitioning from gameplay camera to cinematic camera or the other way around, a continuous transition significantly improves the sense of immersiveness without interrupting game feelings.
- Control over the blend time for most of the time, but also need a way to automatically choose blend time in case we want to constrain the acceleration. During transition, we don't want the movement to change too fast, that is, we'd like to restrict the acceleration. By doing so, the blend time can automatically selected given a viable maximum value of acceleration.
- Control over the shape of blend curve. It's about the speed of movement at each timestamp. Do we want to keep a linear curve on the entire transition process? Or do we want to keep it slow as the transition start and end, and as fast as possible in the middle of transition?
So, does inertialization meet these requirements? Well, not exactly. Inertialization meets the first requirement but not for the second and the third. We must modify the vanilla inertialization algorithm to adapt it to our needs.
Modified Inertialization
Control Over The Blend Curve
Let's start with controlling the shape of the blend curve. From what
we derived above, the inertialization polynomial
The new output value is updated using
As before, we expect
To meet these requirements, we can find such
There are many options for
where
On
Overall, the weighting function
The following figure shows the the weighting function
You can see that by tweaking
Automatic Blend Time
Sometimes it's tricky to determine a good blend time
which creates the most appealing and smooth camera movement. The most
important thing about creating a good camera is, the acceleration should
never exceed a particular threshold. It's not actually about the
velocity: a fast-moving camera at a fixed speed can be very comfortable
to players. To this end, we can constrain the maximum amount of
acceleration
First, we have the second derivative of
This is a third-order polynomial which means it has at most two
extreme points. One of them is known,
Hence, the problem becomes:
There are two equations to solve:
Their solutions, if exist, are:
We discard the negative part, so the final solution will be:
Here are showcases demonstrating the auto blend time respectively
with max acceleration
The 'Right' Way to Inertialize Rotation for Camera
Seems everything goes perfect so far! Let's have a test. The following figure shows an inertial transition from a third person camera to a orbital camera moving at a fixed speed around the center of the scene.
Wait... the camera rolls during transition, but the start camera and the end camera neither has rolls! That's because we're dealing with the axis angle or quaternion instead of the euler angle. Even if both source and target rotations have no rolls, the axis-angle or quaternion interpolation still has the chance to produce roll.
One way to solve the issue is to simply set the roll to zero, and it looks like this:
Better. But the pitch seems does not seem good, since the pitch, yaw and roll are blended as a whole, and only resetting roll leaves pitch not feeling so natural.
To humans, the most natural way to feel the rotation is through yaw, pitch and roll independently. Though this not might be the best choice for blending mathematically, but it should be the most intuitive interpretation to players.
So, we inertialize yaw, pitch and roll as indepent components and
combine them together to the output rotation each frame. But there is
one thing to note, the euler angle of yaw, pitch and roll is not closed,
and rather it's cyclic. In Unreal, a degree of
The following figure shows the rotation without normalization. You can see the camera rotates multiple cycles.
In the following figure, the transition goes through the shortest path with normalization.
That's exactly what we want for rotation!
Conclusion
The insight to use inertialization for camera transition is very intuitive, but with a little modification to suit our needs for cameras. We revisited the core mathematical formula, the inertialization polynomial, and invented several new techniques allowing us to automatically set the blend time, combine with a pre-defined curve, and create a more visually appealing rotation transition feel. I hope you find it helpful!