Webgl 视锥体视图
当我在 webgl 中用 1 个纹理渲染 5 个盒子时,应用程序以 60 fps 的速度运行,很好。但是当我渲染 70 个盒子时,性能下降到约 40fps,但视图体积仍然是 5。
我已经调试了应用程序,所有 70 个盒子都在不需要时使用每个片段着色器,因为其中 65 个盒子不在视锥体之外。我认为 gl.viewport 声明从视图多边形中剪掉了,但事实并非如此。
我想知道 futrum 剔除是否是避免这种情况的技术?如何激活 futrum 剔除?有没有 webgl 命令或者我必须手动执行?
提前致谢,
When I Render 5 boxes in webgl with 1 texture all of them, the app runs at 60 fps, nice. But when I render 70 boxes the performance dicrease to ~40fps but in the view volumes are still 5.
I have debugged the app and all 70 boxes are using per fragment shaders when there are no need because 65 of them are out of frustum. I thought that gl.viewport declaration clipped out of view polygons but not.
I would like to know if fustrum culling is the technique to avoid this? How can I activate fustrum culling? Is there any webgl command or I have to do it manually?
Thanks in advance,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您猜对了:您必须手动完成。
但这种技术是在对象级别的。视口之外的各个三角形应该由硬件自动剔除。
随着盒子数量的增加,您的绘制循环是否可能存在其他效率低下的问题,从而导致速度减慢?例如,您是否为每个盒子绑定纹理?或者使用 getAttribLocation 或 getUniformLocation 查询着色器?或者执行其他 WebGL 查询(所有这些都会显着减慢管道速度)?
You guessed it: you have to do it manually.
But this technique is at the object level.. Individual triangles that are outside the viewport should be culled by the hardware automatically.
Is it possible that your draw loop has other inefficiencies that may be slowing things down as the number of boxes increases? For example, are you binding the texture for each box? Or querying the shader with getAttribLocation or getUniformLocation? Or doing other WebGL queries (all of which will slow the pipeline dramatically)?