大于 GL_MAX_VIEWPORT_DIMS 的视口平铺渲染
我正在创建一个类,它采用 OpenGL 场景图并使用 QGLFrameBufferObject 来渲染结果。为了支持(几乎)无限尺寸,我使用平铺来提取许多小图像,这些小图像可以在渲染所有平铺后组合成大图像。
我通过为整个图像设置视口 (glViewport
),然后使用 glScissor
逐个图块“剪切”图块来进行平铺。这对于高达 GL_MAX_VIEWPORT_DIMS
的分辨率效果很好,但会导致超出此限制的空图块。
我应该如何解决这个问题?我需要改变相机还是有什么巧妙的技巧可以做到这一点?我正在使用 Coin/OpenInventor,因此也非常欢迎针对这些框架的任何提示。
I'm creating a class that takes an OpenGL scenegraph and uses QGLFrameBufferObject
to render the result. To support (virtually) infinite sizes I'm using tiling to extract many small images that can be combined into a big image after rendering all tiles.
I do tiling by setting up a viewport (glViewport
) for the entire image and then using glScissor
to "cut out" tile after tile. This works fine for resolutions up to GL_MAX_VIEWPORT_DIMS
, but will result in empty tiles outside this limit.
How should I approach this problem? Do I need to alter the camera or is there any neat tricks to do this? I'm using Coin/OpenInventor so any tips specific to these frameworks are very welcome too.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
更改相机并不像您想象的那么难,这是除了修改顶点着色器之外我能看到的唯一解决方案。
通过沿 x 轴和 y 轴缩放和平移投影矩阵,您可以轻松获得普通相机视图的任何子区域。
对于给定的最大和最小视口,其中完整视口为 (-1, -1) 和 (1, 1),按 (max + min) / 2 平移,按 (max - min) / 2 缩放。
Changing the camera isn't as hard as you may think, and it's the only solution I can see at all apart from modifying vertex shaders.
By scaling and translating the projection matrix along the x and y axes, you can easily get any subregion of the normal camera's view.
For a given max and min of the viewport, where the full viewport is (-1, -1) and (1, 1), translate by (max + min) / 2, and scale by (max - min) / 2.
提供OpenGL Tile渲染库 尝试一下。
Give the OpenGL Tile Rendering Library a try.
您可以尝试缩小整个世界,间接使视口最大考虑更大的细节。或者基本上,您可以缩小图像和视口并获得相同的视觉效果。
You could try scaling the entire world down, indirectly making the viewport max account for larger detail. Or basically, you could scale the image AND the viewport down and have the same visual effect.