I do a lot of animation where I offset uvs to achieve provedural effects. This results in temporalAA smearing where it can’t predict the motion of the uvs. Is there a way to write to the motion vector pass using uv animation derivatives transformed into screenspace?
Yes. That would need a bit of engine modification, but you can output per-pixel velocities. In fact, it is relatively straight forward, when velocity output from base pass is enabled.
But having tried that in earlier engine versions, I can re-assure you, that it is not going to bring major improvement in most cases.
In this case it’s a texture animating along a water plane on a spline mesh and the smearing is quite obvious. Would be nice to try it and see if it helps. The alternative is animate the vertices but I would imagine that the overall motion vectors would be very similar.
Do you know where I should be looking in the source code to make a modification? It’s been a few years since I made my last modification and I’m a bit rusty with the code base
You’d start at BasePixelShader.usf, towards the end of the file, where velocity gets written, and follow upwards until get previous world position offset is called. That is the point where you need to grab additional input from material and calculate velocity per pixel. That is, provided that you are actually using velocity output from base pass setting. Having same functionality in velocity only pass is too scary for me to think about, because it needs additional velocity shader permutations and a pile of trouble.
I think, in your case, it would be ideal, provided mesh is dense enough. Do note, that you do not actually have to move verts, but can use PreviousFrameSwitch Material expression to have explicit control over velocity while keeping verts on the same place. Likewise, mind static/movable/movable that moved objects, for former two will not write velocities. At least as of 4.25. Last but not least, that works only with WPO, but not displacement.