多少个法线?
如果您正在计算多边形的法线以在 WebGL 上渲染它,您是否为索引数组中的每个索引或顶点数组上的每个顶点使用法线?
if you are calculating the normals of a polygon for rendering it on WebGL, do you use a normal for every index in the index array or for every vertex on the vertex array?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在此处的注释中,用户正在计算每个顶点。
In the notes here, the user is calculating them for each vertex.
每个顶点。在 WebGL 意义上(与 OpenGL ES 和其他前身相同),顶点实际上并不是空间中的一个点,而是属性的组合。其中之一几乎总是位置(尽管在特殊情况下可能没有),其他通常是法向量、颜色、纹理坐标等。
相比之下,索引数组是顶点属性数组的偏移量。因此,当您在索引数组中指定索引(例如)1时,它是“由位置缓冲区中的第一个位置、法线缓冲区中的第一个法线、颜色缓冲区中的第一个颜色和第一个颜色组合而成的顶点”的简写。纹理坐标缓冲区中的纹理坐标”。
当我学习这一点时,对我来说最反直觉的事情是将顶点与其恰好占据的位置分开。两个顶点没有理由不能具有相同的位置。
Every vertex. A vertex, in the WebGL sense (which is the same as OpenGL ES and other predecessors), isn't really a point in space, but rather a combination of attributes. One of these is almost always the location (though in unusual cases you might not have that), and others are generally things like the normal vector, the colour, the texture coordinates, and so on.
The index array, by contrast, is an offset into the vertex attribute arrays. So when you specify index (say) 1 in an index array, it's shorthand for "the vertex made of combining the first location in the location buffer, the first normal in the normal buffer, the first colour in the colour buffer, and the first texture coordinate in the texture coordinate buffer".
The most counter-intuitive thing for me when learning this was separating vertices from the locations they happen to occupy. There's no reason why two vertices can't have the same location.