使用VBO或着色器渲染BSP? OpenGL
是否可以在着色器中渲染游戏中的 BSP 文件?着色器中是否可以有 VBO 还是需要在客户端渲染?
另外,对于 VBO,从当前的 PVS 和视锥体创建可见面数组,然后通过匹配纹理进行批量渲染是否有意义?
Is it possible to render BSP files from games from within shaders? Is it possible to have a VBO in a shader or does it need to be rendered client side?
Also for VBOs does it make sense to create an array of visible faces from your current PVS and frustum and then render then in batches by matching textures?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
着色器不能直接引发渲染。它无法导致 OpenGL 渲染某些数据。着色器是渲染管道的一部分,并且该管道是单向的;不允许循环。
在基于 GL 4.x 的硬件中,着色器理论上可以以特定格式写入数据,这些数据将通过“间接”渲染函数之一读取。但客户端代码(CPU)仍然必须实际发出绘图命令。
使用像 OpenCL 这样的计算语言来做可见性的事情可能会更好。 OpenGL 着色器可以做到这一点,但它们的设计不够直观。 OpenCL 是一个通用计算系统,它被设计用来做这类事情。
A shader cannot directly provoke rendering. It cannot cause OpenGL to render some data. Shaders are part of the rendering pipeline, and that pipeline goes one way; it isn't allowed to loop.
In GL 4.x-based hardware, a shader could theoretically write data in a specific format that will be read via one of the "Indirect" rendering functions. But the client code, the CPU, still must actually issue the drawing command.
It's probably better to do visibility stuff in a compute language like OpenCL. OpenGL shaders are capable of it, but they're not well designed to make doing that intuitive. OpenCL is a general compute system, and it is designed to do that sort of thing.
有了很多 PITA,在 OpenGL-4 类系统上就有可能实现。但为什么?一旦你开始朝这个方向思考,你就在做一些根本性错误的事情。我敢打赌,当前 GPU 上这种基于纯着色器的 BSP 渲染器的性能实际上优于 10 年前的 GeForce2 和编写良好的客户端代码。
请记住各位:在着色器中执行操作 =/= 高性能
OpenGL 从来没有、也永远不会成为一个独立的渲染引擎。它一直被认为是用于自定义编写的渲染器的后端光栅化器 API。
With a lot of PITA it may be possible on OpenGL-4 class systems. But, why? As soon as you start thinking in that direction you're doing something fundamentally wrong. And I'd bet, that such a pure-shader based BSP renderer on a current GPU was actually outperformed by a 10 year old GeForce2 and well written client side code.
Remember folks: Doing things in the shader =/= High performance
OpenGL never has been, and never will be a self-contained rendering engine. It's always been meant as the backend rasterizer API for a customly written renderer.