一直以为,因为一条三角形带(triangle strip)会把处理与传输m个三角形的代价从3m个顶点降到(m+2)个顶点,所以它是最高效的。今天从Gamedev的一篇帖子才知道,索引三角形列表(indexed triangle lists)才是最快的。
确实,三角形带减少了输入显卡的顶点数,但对于现今的显卡来说,带宽早就不是问题了!
至于为什么三角形带是最快的,因为在处理顶点时它可以最大化显卡缓存的使用率(cache hit ratio)。
下面这段话摘自Tom Forsyth的论文Linear-Speed Vertex Cache Optimisation,如何分配三角形的序列,以使的cache得到最好的利用。算法是贪心性质的,速度可以达到O(N),有兴趣可以研究研究。
Indexed primitives have replaced strips and fans as the most common rendering primitive in graphics hardware today. When rendering each triangle, the vertices it uses must be processed (for example, transformed to screen space and lit in various ways) before rendering. Indexed rendering hardware typically uses a small cache of vertices to avoid re-processing vertices that are shared between recently-rendered triangles. Using a moderately-sized cache (anywhere between 12 and 24 vertices is common) reduces the load on the vertex processing pipeline far more than the older non-indexed strips and fans model – often halving the amount of work required per triangle.
Recent Comments