openGL中具有三角形条和矢量法线的多维数据集 [英] Cube with triangle strips and vector normals in openGL

查看:76
本文介绍了openGL中具有三角形条和矢量法线的多维数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用一系列顶点创建多维数据集,例如尝试在此论坛上.我正在寻找的答案应如下所示:

I'm trying to create a cube using one series of vertices such as attempted in this example (which I believe is wrong) and also talked about on this forum. The answer I'm looking for should look something like this:

 1,  1, -1
-1, -1, -1,
 1,  1,  1

...等等.我希望将其降低到最少13个顶点(6面立方体= 12个三角形).

... and so on. I'm hoping to get this down to a minimum of 13 vertices (6 sided cube = 12 triangles).

这可能吗?

推荐答案

最小化三角形/四边形带的顶点几乎没有好处.每个面都有自己的顶点(对于像立方体这样的锋利网格)的一个优点是能够为每个顶点指定不同的法线,这可能对您很重要.具有正确的镜面反射像素照明.

There's little benefit in minimizing the vertices of a triangle / quad strip. One advantage of having each face has its own vertex (for a sharp-edged mesh like the cube) is the ability to specify different normal to each vertex, which might might be important for you if you want to have correct per-pixel lighting with a specular reflection.

(无论如何,如果您不关心法线或其他任何事情:就绝对效率而言,您能做的最好的事情就是只指定8个顶点并使用一个索引数组.这可以使用顶点缓存,因此您的顶点着色器可以使用即使每个顶点被多个面使用,它也可能只运行一次.

(Anyway, if you're not concerned about normals or anything: The best you can do in terms of sheer efficiency is specify just the 8 vertices and use an index array. This enables the use of vertex cache so your vertex shader is likely to run only once per each vertex, even though it is used by several faces).

这篇关于openGL中具有三角形条和矢量法线的多维数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆