glVertexAttribDivisor和glVertexBindingDivisor有什么区别? [英] What is the difference between glVertexAttribDivisor and glVertexBindingDivisor?

查看:551
本文介绍了glVertexAttribDivisor和glVertexBindingDivisor有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找将属性与任意组的顶点相关联的方法,起初,实例化似乎是实现此目的的唯一方法,但是后来我偶然发现了此答案状态:

I was looking for ways to associate attributes with arbitrary groupings of verticies, at first instancing appeared to be the only way for me to accomplish this, but then I stumbled up this question and this answer states :

但是,使用较新版本的OpenGL可能会设置某个顶点属性的缓冲区偏移增加的速率.实际上,这意味着给定顶点数组的数据在属性的缓冲区偏移量增加之前会被复制到n个顶点.设置此除数的功能是 glVertexBindingDivisor .

However what is possible with newer versions of OpenGL is setting the rate at which a certain vertex attribute's buffer offset advances. Effectively this means that the data for a given vertex array gets duplicated to n vertices before the buffer offset for a attribute advances. The function to set this divisor is glVertexBindingDivisor.

(重点是我的)

在我看来,答案似乎是在宣称我可以除以顶点数,而不是实例数.但是,当我查看 glVertexBindingDivisor 的文档并将其与 glVertexAttribDivisor 进行比较两者似乎都指发生在实例而不是顶点上的划分.例如,在glVertexBindingDivisor的文档中指出:

Which to me seems as if the answer is claiming I can divide on the number of vertices instead of the number of instances. However, when I look at glVertexBindingDivisor's documentation and compare it to glVertexAttribDivisor's they both appear to refer to the division taking place over instances and not vertices. For example in glVertexBindingDivisor's documentation it states:

glVertexBindingDivisor和glVertexArrayBindingDivisor可以修改在单个绘制命令中渲染多个图元的实例时通用顶点属性前进的速率.如果除数为零,则使用绑定到bindingindex的缓冲区的属性每个顶点前进一次.如果除数不为零,则每个渲染的顶点集的除数实例都会向属性前进一次.如果相应的除数值不为零,则该属性称为实例化.

glVertexBindingDivisor and glVertexArrayBindingDivisor modify the rate at which generic vertex attributes advance when rendering multiple instances of primitives in a single draw command. If divisor is zero, the attributes using the buffer bound to bindingindex advance once per vertex. If divisor is non-zero, the attributes advance once per divisor instances of the set(s) of vertices being rendered. An attribute is referred to as instanced if the corresponding divisor value is non-zero.

(重点是我的)

那么这两个功能之间的实际区别是什么?

So what is the actual difference between these two functions?

推荐答案

那么这两个功能的实际区别是什么?

So what is the actual difference between these two functions?

现代OpenGL有两个 个不同的API,用于指定顶点属性数组及其属性.传统的glVertexAttribArray和朋友,其中glVertexAttribDivisor也是其中的一部分.

Modern OpenGL has two different APIs for specifying vertex attribute arrays and their properties. The traditional glVertexAttribArray and friends, where glVertexAttribDivisor is also part of.

使用 ARB_vertex_attrib_binding (从GL开始在内核中4.3),引入了新的API,该API将顶点格式与指针分开.期望切换数据指针的速度很快,而切换顶点格式的价格可能会更高.新的API允许分别明确控制这两个方面,而旧的API总是同时设置这两个方面.

With ARB_vertex_attrib_binding (in core since GL 4.3), a new API was introduced, which separates the vertex format from the pointers. It is expected that switching the data pointers is fast, while switching the vertex format can be more expensive. The new API allows to explictely control both aspects separately, while the old API always sets both at once.

对于新API,引入了新的介绍层:缓冲区绑定点. (有关更多详细信息,请参见 OpenGL Wiki .)glVertexBindingDivisor指定属性实例化除数为这样的绑定点,因此它在概念上等同于新API的glVertexAttribDivisor函数.

For the new API, a new layer of introduction was introduced: the buffer binding points. (See the OpenGL wiki for more details.) glVertexBindingDivisor specifies the attribute instancing divisor for such a binding point, so it is the conceptual equivalent of the glVertexAttribDivisor function for the new API.

这篇关于glVertexAttribDivisor和glVertexBindingDivisor有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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