Odd Behave for a vertex animation material

I write a vertex animation shader to simulate grass swing in the wind. It works fine when the material of this shader is applied on a single object. However, things get wired when there’s multiple objects using this same material. They supposed to have phase offset based on their world position but in fact they didn’t. And the mesh wireframe doesn’t match the rendered pixels when observed in Scene view. Can somebody help me out?

This occurs due to dynamic batching. It’s making everything significantly more efficient, but it’s the bane of vertex animation.

There are ways to counter it, but to some extent, you’ll need to ask “is it worth it?”

Dynamic batching is taking your grass and combining it into a single 3D model because your grass all share the same attributes: Namely, they’re all using the exact same material and, to a lesser extent, are generally immobile and using the same 3D model (i.e. a plane).

When this happens, your grass is no longer based around the position each was originally placed at. Instead, when they’re combined, their center now lies at the global origin (0, 0, 0). I’m guessing that your vertex animation is based around local coordinates, such as local y-axis for height offsets, or even just the distance to each grass piece’s origin, so it doesn’t convert to world space correctly.