Getting 'PERFORMANCE WARNING' messages in

2019-07-18 09:49发布

I just recently starting getting these messages, and was wondering if anyone has seen them, or know what may be causing them. I'm using Three.js with Chrome version '21.0.1180.57' on MacOS. I don't get these messages with Safari or FireFox.

PERFORMANCE WARNING: Attribute 0 is disabled. This has signficant performance penalty

WebGL: too many errors, no more errors will be reported to the console for this context.

2条回答
闹够了就滚
3楼-- · 2019-07-18 10:05

Same message on Firefox is : "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."

This is not only a performance drawback, but will also result in bad output.

PROBLEM: This message occurs if a JS tries to run a WebGL shader that is expecting color information in gl_Color on a mesh not providing a color array.

SOLUTION: Use a WebGL shader with constant color not accessing gl_Color or provide a color array in the mesh to be shaded.

If using lightgl.js from Evan Wallace, try to add the option colors:true in the new GL.Mesh statement and provide a propper mesh.colors array of same size as your vertices array. Or try this shader:

blackShader = new GL.Shader(
  'void main() { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; }',
  'void main() { gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); }'
);

Sorry, I never used Three.js but the problem should be similar, provide color to your mesh before shading.

查看更多
登录 后发表回答