Why does my Vertex Animation shader produce different results in Scene and Game view?

Hi!

I’ve been making a game lately, and now I’ve written a simple vertex animation shader which displaces vertices on some vegetation I have, based on some values.

So far, it’s been going OK, but I have some issues when viewing the game side by side with Scene & Game. They produce different results for some reason, and I can’t figure it out. Game and Scene cameras are both set to Isometric.

Here’s how it looks right now:
GIF Link

On the right (Scene) you can see how the vegetation is supposed to look.

Here’s the code bit that is relevant:

// Distance from vertex to model origin.
fixed localDistance = distance(v.vertex.xyz, fixed3(0,0,0));

// Some displacement values.
fixed s = sin(_Time.y * _WindY + v.vertex.x);
fixed c = cos(_Time.y * _WindY + v.vertex.z);

// Add the values to the Y of the vertex.
v.vertex.y += _Shakiness * s * c * localDistance * 0.2;
o.vertex = UnityObjectToClipPos(v.vertex);

(Then we pass the vertex on to the fragment, and so on...)

My guess is that your models are being dynamically batched, which will adjust their coordinates as seen by the vertex shader into worldspace in the game view.
Try adding the

"DisableBatching" = "true"

tag to the top of your shader.

My guess is a problem with time/framerate and somehow that is different in edit mode. Have you tried fixedTime? How / where are you updating the time info?