OpenGLES 3.0 无法渲染大于屏幕尺寸的纹理
我在下面制作了一张图片来表明我的问题。我将场景渲染到屏幕外的帧缓冲区,其纹理大小与屏幕相同。然后,我将所述纹理渲染到填充屏幕的四边形。这会产生图像上的情况 1。然后我运行完全相同的程序,但纹理大小比方说大 1.5 倍(足以包含整个笑脸),然后再次将其渲染到屏幕填充四边形。然后我得到结果 3,但我期望得到结果 2。
我记得在渲染到纹理之前根据新的纹理大小更改视口,并在绘制四边形之前重置视口。我不明白,我做错了什么。
总而言之,这是一般流程(代码太多,无法发布全部):
- 创建
MSAAframebuffer
和ResolveFramebuffer
(Resolve 包含纹理)。 - 设置
glViewport(0, 0, Width*1.5, Height*1.5)
- 绑定
MSAAframebuffer
并渲染我的场景(笑脸)。 - 将
MSAAframebuffer
Blit 到ResolveFramebuffer
- 设置
glViewport(0, 0, Width, Height)
,绑定纹理并渲染我的四边形。
请注意,所有 MSAA 都工作得很好。而且两个缓冲区都具有相同的尺寸,所以当我blit时它很简单:glBlitFramebuffer(0, 0, Width*1.5, Height*1.5, 0, 0, Width*1.5, Height*1.5, ClearBufferMask.ColorBufferBit, BlitFramebufferFilter .Nearest)
希望有人有一个好主意。如果不这样做我可能会被解雇:D
I have made an image below to indicate my problem. I render my scene to an offscreen framebuffer with a texture the size of the screen. I then render said texture to a screen-filling quad. This produces the case 1 on the image. I then run the exact same program, but with with a texture size, let's say, 1.5 times greater (enough to contain the entire smiley), and afterwards render it once more to the screen-filling quad. I then get result 3, but I expected to get result 2.
I remember to change the viewport according to the new texture size before rendering to the texture, and reset the viewport before drawing the quad. I do NOT understand, what I am doing wrong.
To summarize, this is the general flow (too much code to post it all):
- Create
MSAAframebuffer
andResolveFramebuffer
(Resolve contains the texture). - Set
glViewport(0, 0, Width*1.5, Height*1.5)
- Bind
MSAAframebuffer
and render my scene (the smiley). - Blit the
MSAAframebuffer
into theResolveFramebuffer
- Set
glViewport(0, 0, Width, Height)
, bind the texture and render my quad.
Note that all the MSAA is working perfectly fine. Also both buffers have the same dimensions, so when I blit it is simply: glBlitFramebuffer(0, 0, Width*1.5, Height*1.5, 0, 0, Width*1.5, Height*1.5, ClearBufferMask.ColorBufferBit, BlitFramebufferFilter.Nearest)
Hope someone has a good idea. I might get fired if not :D
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现我实际上在代码中的其他地方使用了 AABB 来确定要渲染的内容;这个 AABB 是根据“小视口的大小”计算的。愚蠢的错误。
I found that I actually used an AABB somewhere else in the code to determine what to render; and this AABB was computed from the "small viewport's size". Stupid mistake.