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...)