多少个法线?

发布于 2024-09-06 19:08:51 字数 64 浏览 2 评论 0原文

如果您正在计算多边形的法线以在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鯉魚旗 2024-09-13 19:08:51

此处的注释中,用户正在计算每个顶点。

In the notes here, the user is calculating them for each vertex.

眼眸 2024-09-13 19:08:51

每个顶点。在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文