寻找一些优化 WebGL 3D 引擎的技巧
我完成了 Learningwebgl.com 和 Mozilla 教程,一开始一切看起来都不错,但是……
不幸的是,在制作了大量函数并将脚本分成多个部分(如 core.js、math.js、mesh.js)后,我的第一个引擎速度变慢了。 js 等),所以我陷入了这个性能问题。
现在在 LocalHost 上加载页面需要几秒钟(速度相当快),加载纹理和网格也需要几秒钟,而且 Chrome 刷新几次页面后就死机了,CPU/GPU 使用率异常,甚至我的“WampServer”崩溃了!
我不是 Javascript 大师,但是这个东西(webgl)看起来非常敏感,很容易被任何错误破坏,我用 Canvas2D 制作在线绘画应用程序,从来没有遇到过类似的问题。
我注意到当我将所有脚本放入单个 HTML 或 JS 文件中时,性能比许多小脚本要高得多,也许这就是问题所在?
注意:我没有使用 jQuery 或任何其他库。 (仅限 glMatrix 和 RequestAnimationFrame 脚本)
问题:在从头开始重写我的引擎之前,请给我一些提示,我不想犯同样的错误!
抱歉语言问题
I finished Learningwebgl.com and Mozilla tutorials, everything look good at first, but...
Unfortunately, My first engine slow-down after making lots of functions and also separating scripts into pieces (like core.js, math.js, mesh.js and so on), so I get into this performance issues.
Now it takes few seconds to load page on LocalHost (which is quite fast), and also few more seconds to load textures and meshes, and Chrome freeze down after refreshing page for a few times, CPU/GPU usage is abnormal, and even my 'WampServer' crash down!
I'm not Javascript master, but this thing (webgl) looks very sensitive and easily broken down by any mistake, I make Online Painting application with Canvas2D and never had similar issues.
I notice performance is much higher when I put all the scripts into single HTML or JS file than lots of small scripts, maybe that's the issue?
Note: I'm not using jQuery or any additional libraries. (only glMatrix and RequestAnimationFrame scripts)
Question: Please give me some tips before re-writing my engine from ground up, I don't want to do same mistakes!!
Sorry for language
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现了一篇关于 WebGL 优化的精彩演讲。希望它会有用:
http://www.youtube.com/watch?v=rfQ8rKGTVlg
关于如何改进的部分令人印象深刻WebGL 性能。
I've found one good speech about WebGL optimizations. Hope it will be usefull:
http://www.youtube.com/watch?v=rfQ8rKGTVlg
There is quite impressive section on how to improve WebGL performance.