GLSL Tessellation着色器的三角形/面数是多少? [英] GLSL Tessellation shader number of triangles/faces?

查看:92
本文介绍了GLSL Tessellation着色器的三角形/面数是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了三角形的曲面细分着色器,如上的示例所示网站.

I have implemented a triangle tessellation shader as shown in the example on this website.

如何确定已定义的interouter细分因子的输出面总数? -它不会以任何方式影响我的程序,我只想知道我的多边形/面数.

How can I determine the total number of faces that would be output for defined inter and outer tessellation factors? - It doesn't effect my program in any way I would just like to know my poly/face count.

推荐答案

可以使用简单的递归找到单个三角形的重心细分的三角形数量(内部和外部细分相等).

The number of triangles for the barycentric subdivision of a single triangle (where the inner and outer subdivision is equal) can be found using a simple recursion:

// Calculate number of triangles produced by barycentric subdivision (i.e. tessellation)
// Where n is the level of detail lod and outer and inner level is always equal
int calculateTriangles(int n) {

    if(n < 0)   return 1;                               // Stopping condition
    if(n == 0)  return 0;
    return ((2*n -2) *3) + calculateTriangles(n-2);     // Recurse
}

这篇关于GLSL Tessellation着色器的三角形/面数是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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