Longer lasting trace

Guten tag everyone!
i’m tryng to hack some ready made shader to make a videotrace last for a long time.
I want to do this on a video clip, that’s way i guess i can’t simply use someting like feed-back.I mean i can’t render a video texture and then using it like a texture again over the previous one right?
i’ve tried with IIR filter and with timeblur from Pete’s freeframe plugins (http://www.petewarden.com/) but it’s not enough for my goal.
what i’d like to do is to use the 04_difference pixelshader and implement it with further function: i’d like to collect differnce’s between the frames and to add each difference to the initial frame to form a trail. The amount of trail ought to be ruled by a treshold.
THe question is i have no idea of how to extend this shader.any sggestion there?
// -------------------------------------------------------------------------
// PIXELSHADERS:
// -------------------------------------------------------------------------

//bypass see the input
float4 bypass(vs2ps In): COLOR
{
//texture lookup to access the pixels of the texture
float4 col = tex2D(SampSubtrahend, In.TexCd);
//do nothing
return col;
}

//difference beetween texture reference and subtrahend (video in)
float4 difference(vs2ps In): COLOR
{
//texture lookup to access the pixels of the texture
float4 ColReference = tex2D(SampReference, In.TexCd);
float4 ColSubtrahend = tex2D(SampSubtrahend, In.TexCd);
//make the math difference
float4 Difference = ColReference-ColSubtrahend;
//make everything positiv
//trick: small diff are less value then big diff
Difference = Difference*Difference;
//grayscale conversation - everything is converted into black&white
float luma_dif = dot(float3(0.222, 0.707, 0.071), Difference.rgb);
//trick: instad of if (luma_dif > threshold) then Difference alpha = 1
//more faster than if (try to avoid ifs)
Difference.a = luma_dif > threshold;
//mask
Difference.rgb = ColSubtrahend.rgb;
return Difference;
HERE I WOULD NEED IT TO RETURN STORED DIFERENCES BETWEEN FRAMES AN NOT TO REPLACE EACH ONE WITH THE SUBSEQUENT…
}
cheerSARA