OpenGLES 3.0 无法渲染大于屏幕尺寸的纹理

发布于 2025-01-14 16:39:42 字数 945 浏览 7 评论 0原文

我在下面制作了一张图片来表明我的问题。我将场景渲染到屏幕外的帧缓冲区,其纹理大小与屏幕相同。然后,我将所述纹理渲染到填充屏幕的四边形。这会产生图像上的情况 1。然后我运行完全相同的程序,但纹理大小比方说大 1.5 倍(足以包含整个笑脸),然后再次将其渲染到屏幕填充四边形。然后我得到结果 3,但我期望得到结果 2。

我记得在渲染到纹理之前根据新的纹理大小更改视口,并在绘制四边形之前重置视口。我不明白,我做错了什么。

问题显示为图像!

总而言之,这是一般流程(代码太多,无法发布全部):

  1. 创建 MSAAframebufferResolveFramebuffer (Resolve 包含纹理)。
  2. 设置 glViewport(0, 0, Width*1.5, Height*1.5)
  3. 绑定 MSAAframebuffer 并渲染我的场景(笑脸)。
  4. MSAAframebuffer Blit 到 ResolveFramebuffer
  5. 设置 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.

problem shown as an image!

To summarize, this is the general flow (too much code to post it all):

  1. Create MSAAframebuffer and ResolveFramebuffer (Resolve contains the texture).
  2. Set glViewport(0, 0, Width*1.5, Height*1.5)
  3. Bind MSAAframebuffer and render my scene (the smiley).
  4. Blit the MSAAframebuffer into the ResolveFramebuffer
  5. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

悲念泪 2025-01-21 16:39:42

我发现我实际上在代码中的其他地方使用了 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文