我是否必须在Unity中使用网格中的共享顶点?

时间:2016-04-25 14:32:59

标签: unity3d graphics shader

我想在Unity3D中创建具有平面阴影外观的程序生成的横向网格。

我认为最好每个三角形创建三个独特的顶点,并为顶点使用一个计算的法线。构建此网格将导致冗余的顶点位置信息。 (它会对渲染时间产生影响吗?)

无论如何......问题是我想使用着色技术,例如此网格上的环境遮挡。我不想弄乱Unity3D对其着色器所期望的网格拓扑。

使用共享顶点创建网格物体是否更好,可能添加自定义顶点属性,例如'flat_normal'并自定义着色器以使用它?

2 个答案:

答案 0 :(得分:3)

简单的答案是

否,

Unity没有,丝毫没有"寻找"共享顶点。没有3D管道与共享顶点有任何关系。无论如何,共享顶点无论如何都无助于或阻碍3D管道。

(很多时候,例如,当我们制作动态网格时,我们只是"根本不使用共享顶点"因为,正如您可能已经发现的那样,它通常比不使用共享顶点。)

使用共享顶点的唯一原因是,出于某种原因,它恰好使您更方便。在这种情况下,3D管道(Unity或其他地方)"允许"共享顶点,没有缺点。

答案 1 :(得分:1)

There might be 2 considerations for using shared vertices:

  • To reduce memory usage. (Only slightly, but if you need less UV1's, UV2's, normals, vertices it can add up)
  • to make it more convenient to share normals. (You only have to alter one normal of a vertex if you want to keep the surface smooth. )

These are no big reasons, but as most of the meshes from other 3D programs that you encounter, it's probably best to get used to shared vertices.

相关问题