int gl_VertexID中导致Three.js错误 [英] in int gl_VertexID causing error with three.js
问题描述
我一直无法使用使用in
传递的内置于顶点索引中的gl_VertexID来与Three.js一起使用
I've been having trouble with the gl_VertexID built in vertex index, passed using in
, to work with Three.js
我不确定为什么,因为文档说它可以在所有版本的OpenGL中使用
I'm not sure why, as the documentation says it works in all versions of OpenGL
http://www.opengl.org/sdk/docs/manglsl/xhtml/gl_VertexID.xml
我正在使用此顶点着色器:
I'm using this vertex shader:
uniform int freqData[64];
uniform int fftSize;
in int gl_VertexID;
void main() {
vec3 norm = normalize(position);
int modFFT = mod(gl_VertexID, fftSize);
vec3 newPosition = norm * float(freqData[modFFT]);
gl_Position = projectionMatrix * modelViewMatrix * vec4( newPosition, 1.0 );
}
我收到的错误是:
ERROR: 0:68: 'in' : syntax error
in
声明似乎有问题,并且没有其他问题(错误控制台能够检测到多个编译错误).
It seems to have a problem with the in
declaration, and it doesn't complain about anything else (the error console is able to detect multiple compilation errors).
非常感谢您的帮助,我正在使用昨天的Three.js版本.
I very much appreciate your help, I'm working with yesterday's Three.js build.
推荐答案
据我所知,在WebGL中,您无法访问内置的顶点索引.
As far as I'm aware, in WebGL you can't access built-in vertex indices.
但是,您应该能够通过提供自己的自定义属性流来模拟这一点,将其设置为与此类内置索引流等效的值.
However you should be able emulate this by providing your own custom attribute stream, set to values that would be equivalent to such built-in index stream.
在three.js中,尚未实现整数自定义属性,因此您需要使用float属性.
In three.js there are no integer custom attributes implemented yet, so you would need to use float attribute.
在此示例中检查位移"属性:
Check "displacement" attribute in this example:
http://mrdoob.github.com/three.js/examples/webgl_custom_attributes.html
这篇关于int gl_VertexID中导致Three.js错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!