Consider the following scenario:
Camera "C" is moving right at speed 0.5 pixels/frame. An object "O" is also moving right at speed 0.5 pixels/frame. Both C and O have a subpixel position. C starts at 0, and O starts at 0.5 (so they have the same speed, but are in different phase).
O_c is the object transformed to camera space (by subtracting camera position)
t is time (frame number)
As you can see, the object stays still at 0.5 pixels, as it should. But if we floor the camera and object coordinates before transform (as often is natural):
Now the object coordinate jitters between 0 and 1 pixels. This looks bad, because the object is supposed to be moving right, but visually takes a step back every now and then.
Here's how it could look in practice. The camera is centered at the object at left, and the object at right is moving at the same speed, different phase. (This short animation doesn't really show the problem that well. The jitter looks quite annoying in practice at full speed.)
jitter.gif [ 9.82 KiB | Viewed 3124 times ]
Is it possible to fix this problem without taking the subpixel position into account when calculating O_c?
Camera "C" is moving right at speed 0.5 pixels/frame. An object "O" is also moving right at speed 0.5 pixels/frame. Both C and O have a subpixel position. C starts at 0, and O starts at 0.5 (so they have the same speed, but are in different phase).
O_c is the object transformed to camera space (by subtracting camera position)
t is time (frame number)
Code:
t C O O_c
---------------------------------------------
0 0 0.5 0.5
1 0.5 1.0 0.5
2 1.0 1.5 0.5
3 1.5 2.0 0.5
---------------------------------------------
0 0 0.5 0.5
1 0.5 1.0 0.5
2 1.0 1.5 0.5
3 1.5 2.0 0.5
As you can see, the object stays still at 0.5 pixels, as it should. But if we floor the camera and object coordinates before transform (as often is natural):
Code:
t floor(C) floor(O) O_c
---------------------------------------------
0 0 0 0
1 0 1 1
2 1 1 0
3 1 2 1
---------------------------------------------
0 0 0 0
1 0 1 1
2 1 1 0
3 1 2 1
Now the object coordinate jitters between 0 and 1 pixels. This looks bad, because the object is supposed to be moving right, but visually takes a step back every now and then.
Here's how it could look in practice. The camera is centered at the object at left, and the object at right is moving at the same speed, different phase. (This short animation doesn't really show the problem that well. The jitter looks quite annoying in practice at full speed.)
Attachment:
jitter.gif [ 9.82 KiB | Viewed 3124 times ]
Is it possible to fix this problem without taking the subpixel position into account when calculating O_c?