【问题标题】:WebGL VBO and Integer Overflow depending on variable being attribute, uniform or a mixWebGL VBO 和整数溢出取决于变量是属性、统一还是混合
【发布时间】:2015-06-07 08:14:16
【问题描述】:

所以我有这个 WebGL 顶点着色器:

precision mediump float;
uniform mat4 camera;
uniform vec3 pos0;
uniform float time;
attribute float t0;
attribute vec3 dir0;

void main() {
    float t = time - t0;
    gl_Position = camera * vec4(dir0, 1);
    gl_PointSize = 10.0;
}

效果很好,但如果我只更改以下行

gl_Position = camera * vec4(pos0 + dir0 * t, 1);

Firefox 抱怨:

Error: WebGL: drawElements: no VBO bound to enabled vertex attrib index 0!

如果我将同一行更改为以下内容:

gl_Position = camera * vec4(pos0, 1);

错误不同:

Error: WebGL: Drawing without vertex attrib 0 array enabled forces the browser to do expensive emulation work when running on desktop OpenGL platforms, for example on Mac. It is preferable to always draw with vertex attrib 0 array enabled, by using bindAttribLocation to bind some always-used attribute to location 0.
Error: WebGL: Integer overflow trying to construct a fake vertex attrib 0 array for a draw-operation with -1 vertices. Try reducing the number of vertices.

发生了什么事?

编辑:Chromium 给出了更清晰的错误信息:

glDrawElements: attempt to access out of range vertices in attribute 1

【问题讨论】:

  • 你是如何设置你的制服和属性的?你能发布你的代码吗?

标签: glsl webgl vertex-shader


【解决方案1】:

抱歉没有发布更多代码,我认为原因只是在着色器中,但事实并非如此。

我用的是elm-webgl,属性应该设置好了。但是库确实(没有)理解float 属性,所以它们没有被设置。

因此,如果您遇到类似的错误,请检查您是如何设置制服和属性的。

【讨论】:

    猜你喜欢
    • 2019-05-16
    • 1970-01-01
    • 2013-07-06
    • 2011-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多