【发布时间】:2017-03-15 20:50:54
【问题描述】:
我最近一直在制作游戏,现在我编写了一个简单的顶点动画着色器,它根据一些值置换我拥有的一些植被上的顶点。
到目前为止,一切正常,但在与 Scene & Game 并排查看游戏时遇到了一些问题。由于某种原因,它们会产生不同的结果,我无法弄清楚。游戏和场景相机都设置为等距。
这是它现在的样子: GIF Link
在右侧(场景),您可以看到植被的外观。
这是相关的代码位:
// 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...)
【问题讨论】: