Flash shadows - Delayed outlining

Hi everyone

I have a question about delayed outlineing of game character. I found this source , which gives a simple 2d filter to create outlines of objects in the scene.

I want to achieve an effect, that when my character moves ( in some situations), the body of the character will create some lines which have the shape of the character following him for very short time. I guess (hope) this can be modified somehow.

I prepared this blend file with the code and a test animation for that.

Ghostlines.blend (521 KB)

 uniform sampler2D bgl_RenderedTexture;    uniform sampler2D bgl_DepthTexture;


    void main()
    {
       float depth = texture2D( bgl_DepthTexture, gl_TexCoord[0].xy).r;
       float depth2 = texture2D( bgl_DepthTexture, gl_TexCoord[0].xy + vec2(0,0.010)).r;
       float depth3 = texture2D( bgl_DepthTexture, gl_TexCoord[0].xy + vec2(0.010,0)).r;
       
       float fac = abs(depth-depth2) + abs(depth-depth3);
       
       float intensity = 300;


       vec4 sub = vec4(fac*intensity,fac*intensity,fac*intensity,0);
       
       gl_FragColor = texture2D( bgl_RenderedTexture, gl_TexCoord[0].xy ) - sub;
    }

This is an example of the idea i want to achieve. The first ranked character will have pink lines around him. Skip the video to 1:00 and 1:52. Thank you in advance

is this effect not achievable in BGE?

Hmmm… It is possible, but a little bit of overkill for most projects.

What I mean is that in most situations, the effort needed to replicate that effect would not be worth the effect.

However, your game is all focused on the character so it might be worth putting in the effort.

The GLSL filter you’ve made is a good step, but with a high poly character like you use, it’ll probably use too much processing power.

For a simple highlight you can just duplicate the mesh and flip the normals:

Or if you want more like in your video do that for some key poses of your character, apply deformation (so the pose becomes real) now you have some flash shadows of your character in various poses. When dancing you can add those objects in the same position as your character at the same instant your character pose hits those keyframes. You should use an object color animation to fade out the flash shadow quickly so it doesn’t look strange.

thanks smoking mirror, so you mean i should make an object that has the shape of the character and then transfer the weight of the character onto that shape?

I’ll try to post an example of what I mean tonight…

thanks smoking mirror

OK, so here’s what I would do:

saturday_nigh_fever.blend (802 KB)

The flash shadows are copies of the main mesh. I’ve first applied the armature modifier, which freezes the pose in that position. Then I flipped the mesh faces so it is inside out. I’ve given it a additive type blend material with object colors.

Using a list of special key frames (those which are exciting or extreme poses for the character) I add this flash shadow in to the game at the same position as the character. You should unparent the flash shadows from the armature otherwise they probably won’t work properly. The flash shadows have a simple action which is just key framed object color. This makes them fade out over 30 frames. You can make it faster or slower.

Some things you could do to improve this:
Give the flash shadows a texture, perhaps an animated texture.
Make the flash shadows expand slightly as they fade. You could use shape keys…
Instead of adding static meshes, you could add fully rigged flash shadows, set up to do a slightly different move. The flash shadows could be doing dance moves which compliment the main action.
By getting bone position and orientation you could add sparkles that spread out from the arms and legs.

Thanks alot smoking mirror

The effect you made looks fancy, its truely what i want to achieve. But the game i make will have very many dance animations and each of them just have about 480 - 960 frames (8 beats to 16 beats ). So i am sure the way with creating ‘ghost’ - mesh is kinda too time consuming.

I think the option of spawning sparklers from different joints and parts of character is somehow more effective. I will try that.

Well, how about using the add object with a full armature? I tried a little more experiments after posting that one and I ended up with this:

saturday_night_fever2.blend (810 KB)

On the second layer there is a duplicate armature. When added it plays and action with a start and a stop value = to the frame the main armature is playing. So you only need to set up the duplicate armature and flash shadow mesh once and you can have it add flash shadows on any frame you like…

wow it is elefantastic! Thanks smoking mirror!