I'm trying to draw previous frame of animation on screen

you can see this effect here: https://youtu.be/WNL_KJNl6pU

Mortal Combat X (left) , Street Fighter Alpha 2 (right):

Johnny slides in to land a hit, leaving behind a glowing green trail that looks like multiple instances of himself Cammy jumps up to kick, and leaves behind previous visible ghosts of herself

This effect also found in animation software and called onion skinning:

a deer's gallop

I've implemented this by spawning object every second but I think It is possible with shader.


I could make this effect by using RenderTexture for capturing previous frame , but I can't remove background color :(

I tried with Blending and grab pass but don't work(it was rendered normally)!!

sources :



several dozen 3D models in a trailing line

  • 4
    \$\begingroup\$ Possible duplicate of Create a trailing, ghosting effect of a sprite \$\endgroup\$ – John Hamilton May 5 '17 at 9:19
  • 2
    \$\begingroup\$ Have you looked into object pooling to avoid the performance hit of repeatedly spawning copies in your trail? \$\endgroup\$ – DMGregory May 5 '17 at 10:13
  • \$\begingroup\$ Can you confirm this is for 3d? I think that would make it different enough from the suggested duplicate to keep it open. \$\endgroup\$ – MichaelHouse May 9 '17 at 11:53
  • \$\begingroup\$ @Byte56 yeah I actually work on 3d games.my question is for 3d and isn't duplicate.sorry why my question is close?!?! which questions is close? \$\endgroup\$ – Seyed Morteza Kamali May 9 '17 at 18:07
  • \$\begingroup\$ It's not closed, there was a vote in progress to close this question as a duplicate of the 2D specific question linked above. \$\endgroup\$ – MichaelHouse May 10 '17 at 7:25

I would solve this using post processing. You find some way to mask out your ghosting objects (stencil buffer, render layers, w/e) then create a compositing PP effect that combines the current render with the previous renders at a lower opacity. Since you're just pasting new information on top of the old render, you can stack all the previous renders in one texture. This is essentially onion skinning.

You would control how many "ghosts" get displayed based on how quickly you decrease your opacity.

The quick proof of concept I made looks like this (they already faded before I got the screenshot) enter image description here

| improve this answer | |
  • \$\begingroup\$ how can I combine current render with the previous renders?!?! I'm new to shader please write onion skinning shader in your answer.thanks \$\endgroup\$ – Seyed Morteza Kamali May 5 '17 at 18:47
  • 3
    \$\begingroup\$ Note that this solution is limited to a fixed camera position. If the camera is also moving, this won't work as expected. And @smkplus Don't expect all the work to be done for you, you'll need to make an effort. \$\endgroup\$ – MichaelHouse May 10 '17 at 7:27
  • \$\begingroup\$ @SeyedMortezaKamali Did you come up with a proper solution for saving previous renders yet? \$\endgroup\$ – Marten Zander Nov 5 '19 at 16:21
  • \$\begingroup\$ @MartenZander what games do you want to make? there are two solution for trailing ghost effect gh 1.RenderTexture 2.Object pooling \$\endgroup\$ – Seyed Morteza Kamali Nov 5 '19 at 17:26
  • \$\begingroup\$ @SeyedMortezaKamali actually it's not a game I am working on. it's a demonstrator app, using a static camera. So I guess I would go for the RenderTexture way. \$\endgroup\$ – Marten Zander Nov 5 '19 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.