Skip to main content
gamedev.net
🔒 Locked

Movement Shadow

Started by StratBoy61 2 replies 900+ views
Original Post
StratBoy61
StratBoy61
Hello, Well, I have a quick question and I thought that I could get the answer here. I saw on a 3D demo --using openGL I assume, a cool effect of movement shadow ; maybe there is a specific term for that, and it would explain why I could not find it on google. So the picture below shows the effect ; it is from a nice demo about network synchronization with a physics engine (it is called Zen of Networked Physics). While moving around, the cube leaves a kind of shadow trace of its movement. I guess it is also used in fight animations a lot. Would anybody know by any chance how this is done --preferably using DirectX ? Thank you in advance StratBoy61
hplus0603
hplus0603
There are at least three ways this can be done.

1) Instead of clearing the screen, just paint a half-opaque black quad over it. This leaves "traces" of the old image on the screen. However, to make the ground not draw over the old image, you can't clear the Z buffer, which means that the cube must move towards you to keep rendering correctly.

2) Copy the screen, after it is finished, to an accumulation buffer or offscreen texture. After you have rendered the screen (before you copy it the next time), draw that texture/accumulation buffer to the screen with a faint alpha blend. This leaves trails that slowly fade away.

3) Remember the N previous positions of the cube, and draw them using an alpha blend mode, in addition to drawing the actual cube opaquely. You might want to use stencil testing (or destination alpha) to avoid drawing the same pixel twice while drawing the trail.

(Actually, there are more ways, like calculating the geometry of the movement path, etc, but these should suffice).
enum Bool { True, False, FileNotFound };
deavik
deavik
Quote:
Original post by hplus0603
1) Instead of clearing the screen, just paint a half-opaque black quad over it. This leaves "traces" of the old image on the screen. However, to make the ground not draw over the old image, you can't clear the Z buffer, which means that the cube must move towards you to keep rendering correctly.

Just a question: I don't quite understand why one must clear the depth buffer - I thought you'd want to draw the ground afresh? If you just clear the depth buffer and not clear the color buffer, it would almost be the same as having an offscreen texture of last frame's render (only cheaper). Most probably I'm missing something obvious, but I would be happy if someone could point this out for me. [smile]

edit: I just realised that this wonder-method won't work if you're doing anything that requires more than 1 pass. [sad]
StratBoy61
StratBoy61
Thank you hplus0603 for your quick answer.

I guess I should opt for your third solution, because the 2 firsts do not seem to offer a ghost effect for one single object among other objects in a scene. As a matter of fact, I would like to use this effect for say, only one object in the middle of others that would not have this effect while moving.

Do you see any other way of doing it ? Which way do you think is the best option in term of complexity/performance ?
Thank you in advance
StratBoy61

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.