Render 3D trail effect?

Anyone how to render 3D trail effect?

What’s the chance.
There is code at the bottom

woo, cool. is the flag animation using the same technique?

no not at all, the flag vertices are constant in place (relative to the moving geometry). They have spring physics for the segments and some form of sin wave to approximate how cloth moves in wind. Interestingly this problem (cloth moving in wind) is not fully understood/explored yet if you google for scientific papers.

i had try to implement the approach in ur article, there is some function missing


which do not come with monogame framework, can you provide the function? and what is the “visibility” input value for update?

NormalizeLocal is the same as Normalize(), except one can use the Vector right away.

public static Vector3 NormalizeLocal(this Vector3 vec3)
            if (vec3 == Vector3.Zero) return vec3;
            return vec3;

Saturate is clamp between 0 and 1

    public static float Saturate(this float input)
        if (input < 0) return 0;
        if (input > 1) return 1;
        return input;

Visibility is the alpha value the trail has at the start. So usually 1.

1 Like

thank you bro…

sry to is disturb u again, i got this error in ur shader.

i got it. just commend output position

sry to is disturb again, i got uv problem, which only render red color part in texture.

Try this

VertexShaderTexturedOutput VertexShaderTrailFunction(float4 Position : SV_POSITION, float2 TexCoord : TEXCOORD0, float Visibility : TExCOORD1)
VertexShaderTexturedOutput output;

float4 worldPosition = mul(Position, WorldViewProjection);

float vis = saturate(Visibility * 3 – 1);
output.Color = GlobalColor * vis * float4(0.65f,0.65f,0.65f,0.5f);
output.TexCoord = float2(vis, TexCoord.y);
return output;

this will fade out to other colors as it fades out.

Otherwise you just have to change the texCoord.y of the vertices depending on distance from teh beginning, you have to do that in c# code.

1 Like

it’s work Thanks…:slight_smile: