Are motion vectors written for objects that animate via shader (vertex position)

We have trees and grass that sway in the wind via our Shader Graphs. We displace the vertex position to give the grass, branches and leaves motion.

Will this kind of motion be taken into account when motion vectors are updated? Or would it simply skip the object because the transform hasn’t moved, and even if the transform moved, it would write motion vectors only based on the movement of the object as a whole? (I’m using per-object motion in this case).

Motion vectors won’t be updated automatically if you do this.

However, you can do it yourself by checking this on the graph setting on the shader graph.

In that case - I wonder about the units / space / etc for this custom motion vector (I haven’t checked the documentation yet). Also, this will require that I track state between frames - for example how far did the wind move the vertex in this frame, vs. the previous frame… so any ideas how to feed this per-vertex type state into a shader? :slight_smile:

EDIT: actually scrap the question about the state. I would just need a duplicate set of the same wind parameters from the previous frame, then calculate two vertex offsets to figure out the difference.

Here’s what the documentation says. I’m guessing this is the offset between the current local position and the previous local position? Or is this in some other space coordinates?

9351650--1308101--custom-motion-vector.png

It seems to be object space indeed.
I’ll make sure documentation gets updated with that information :slight_smile: