Game Development Community

Animation ghosting

by Brad Schick · in Technical Issues · 05/07/2002 (1:45 am) · 0 replies

I am trying to solve a puzzling animation quality problem that I hope someone might have more experience with.

Background Info
My game renders 2D sprites using DirectDraw3 surfaces. It is a non-exclusive windowed application. I am using an off-screen buffer, but since the game is windowed I only move the out-of-date portions of the back buffer to the primary surface during each update. Only 1 rect per sprite is transferred from the back buffer to the primary surface for the erase and position update (the rect includes both the old and new positions).

The Problem
When the sprites are moving across the screen, they appear to have ghosts. The strange thing is that I see a ghost image in a position where the object never actually should be on the screen. The ghost image is in between each of the final screen positions. While the object is moving it looks like there are 2 (somewhat flickery) instances moving together. About like this (I just photoshoped this):

dev.robotbattle.com/images/rbanim2.png
To create the next image, I changed my code to not erase old positions from the back buffer. You can see that the actual rendered screen positions are further apart than the ghosts (the balls never overlap)

dev.robotbattle.com/images/rbanim.png
I noticed that when my game updates at the same frequency as the monitor's refresh rate the animation looks clean. When the game updates at 1/2 the refresh rate (meaning 42.5hz on a 85hz monitor) I see 2 flickery ghost copies moving together. When the game updates at 1/3rd the refresh rate, I see 3 instances that flicker more slowly and are closer together. The trend continues, but beyond 4 the updates are so slow that the animation just looks choppy.

At first I thought the issue was tearing, but I added a call to DirectDraw::WaitForVerticalBlank just before the blit to screen and it made no difference (also it doesn't really look like tearing). I then thought it might be an illusion caused by un-even animation speeds, but I added a time delta checks and the game is updating at a fairly constant rate.

Any insights? I am stumped.