Vertex position at last frame

I’m trying to calculate individual velocity of the vertex/pixel. As there are some other things involved in the material, I just want to make sure that custom expression is correct:



float4 clip = mul(float4(WSP.xyz,1), View.WorldToClip);
float4 prevclip = mul(clip, View.ClipToPrevClip);
float4 prevview = mul(prevclip, View.PrevClipToView);
float4 prevpos = mul(prevview, View.PrevInvViewProj);
return float3(prevpos.xyz);

WSP is Absolute World Space Position at current frame, the point of these transformations is to get world space location at previous frame. Maybe there is easier way or I’m missing something?

Hey Bored Engineer,

Sorry to revive this thread after so long - but I was wondering if you found the proper way to do this? I’ve tried using the built-in Velocity functions / buffer but am not getting valid data from those. I’m looking into implementing it directly (as is done by PostProcessTemporalAA.usf) but have not had any luck. Did you ever determine how to get the proper velocity?