Adobe 所说的 VertexShader 的输入限制为 8 个到底是什么意思?
这是否意味着每个顶点的数据集总共只能传递 8 个浮点 值?
这是否意味着您只能拥有以下其中一项?
- FLOAT_4 的 2 个输入。
- FLOAT_2 的 4 个输入。
- FLOAT_1 的 8 个输入。
- 是否有任何混合物总计可以达到 8 个浮点 值?
是这样吗?因为如果是的话,他们的文档中说可以使用 8 个输入确实具有误导性。
也许我遇到了麻烦,因为我没有正确格式化数据,但我尝试在每个顶点使用9个浮点,如:
- va0 将是 < strong>FLOAT_4,偏移量设置为0。
- va1 将是 FLOAT_4,偏移量设置为 4。
- va2 将是 FLOAT_1,偏移量设置为 8。
但在这个实验中,屏幕上什么也没有出现。我是否超出了 VertexShader 输入限制?
Does it mean only a total of 8 float values can be passed per vertices's set of data?
Does this mean you can only have one of the following?
- 2 inputs of FLOAT_4.
- 4 inputs of FLOAT_2.
- 8 inputs of FLOAT_1.
- Any mixture that will add up to a total of 8 float values?
Is this the case? Because if it is, it's really misleading in their documentation to say 8 inputs can be used.
Maybe I'm having trouble because I haven't formatted my data correctly, but I'm trying to use 9 floats per vertices, as in:
- va0 would be a FLOAT_4, offset set at 0.
- va1 would be a FLOAT_4, offset set at 4.
- va2 would be a FLOAT_1, offset set at 8.
But nothing appears on the screen with this experiment. Am I exceeding the VertexShader inputs limit?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信限制不是关于顶点的大小,而是关于 GLSL 着色器中顶点属性的数量。
我对 Stage3D 不太熟悉,但这更多是一个 OpenGL 问题。在纯 OpenGL 中,您必须使用函数
glEnableVertexAttribArray(int)
启用顶点属性。此限制意味着此方法的唯一有效数字是 0 到 7。以更容易检查您自己的代码的方式,这在顶点着色器中是不允许的:
注意:属性的大小 (vec2-4 )没关系,事实上有 9 个属性就超过了限制。
I believe the limit is not about the size of vertices, but about the number of vertex attributes in your GLSL shader.
I'm not too familiar with Stage3D, but this is more an OpenGL question. In pure OpenGL, you have to enable vertex attributes with the function
glEnableVertexAttribArray(int)
. What this limitation means is that the only valid numbers for this method are 0 through 7.In a way that is easier to check against your own code, this isn't allowed in a vertex shader:
Note: size of attributes (vec2-4) don't matter, the fact that there are 9 attributes would be passing the limit.
好的,所以我发现了问题。
如果您在顶点数据(每个顶点)中定义更多值,例如从此格式进行修改:
到类似这样的内容:
太棒了...您向混合中添加了一个新寄存器。但你必须做的是:
确保在以下位置传递正确的值:
context3D.createVertexBuffer(numOfVertices, vertexDataLength);
和...uploadFromVector(_vertexData, 0, numOfVertices);
确保在调用中设置正确的偏移量至:
context3D.setVertexBufferAt(2, vertexBuffer, 8, Context3DVertexBufferFormat.FLOAT_4);
如果您添加了新的顶点属性,但没有在 AGAL 代码中使用它...它将不会渲染!
希望这可以节省其他人一些时间来思考他们的着色器出了什么问题!
注意:我知道,常识 - 如果你创造了一些东西,为什么你不使用它呢?我正在测试以前的着色器是否仍然可以使用额外的数据。确实如此,只要我不在混合中分配新的顶点属性(va2)即可。因此,如果您正在测试,请确保仅将
setVertexBufferAt(...)
与您实际使用的输入寄存器一起使用。Okay, so I found the problem.
If you define more values in your vertex-data (per vertices), such as making a modification from this format:
to something like this:
Great... you added a new register to the mix. But what you have to do is:
Make sure to pass in the right values in:
context3D.createVertexBuffer(numOfVertices, vertexDataLength);
and...uploadFromVector(_vertexData, 0, numOfVertices);
Make sure you set the right offsets in your calls to:
context3D.setVertexBufferAt(2, vertexBuffer, 8, Context3DVertexBufferFormat.FLOAT_4);
If you added a new vertex-attribute but you don't use it in your AGAL code... it won't render!
Hopefully this saves others some time wondering where they went wrong with their shaders!
Note: I know, common sense - if you create something, why wouldn't you use it anyways? I was testing if the previous shader still worked with the extra data. It does, as long I don't assign my new vertex-attribute (va2) in the mix. So if you're testing, make sure to only use
setVertexBufferAt(...)
with the input registers you'll actually use.