渲染到纹理与渲染到 CAEAGLLayer 支持的视图?

发布于 2024-12-21 19:54:55 字数 94 浏览 3 评论 0原文

我对 OpenGL 环境的掌握非常松散,所以这是我试图理解的东西。有人可以通俗地解释一下这两种渲染风格之间有什么区别吗?我主要想了解渲染纹理意味着什么以及何时适合选择这样做?

I have a very loose grasp of the OpenGL environment, so this is something I'm trying to understand. Could someone explain in lay terms what is the difference between these two styles of rendering? Primarily I would like to understand what it means to render to a texture and when would it be appropriate to choose to do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

琴流音 2024-12-28 19:54:55

如果渲染到纹理,则渲染的图像将以使其立即可用作纹理的方式进行处理,这在实践中通常意味着 CPU 的工作量可以忽略不计或为零。通常,您将渲染纹理作为更复杂的渲染管道的一部分。

阴影缓冲区是最明显的例子——它们是渲染阴影的一种方式。您将相机放置在光源所在的位置并从那里渲染场景,以便最终的深度信息最终出现在纹理中。您不会向用户显示这一点。对于您打算向用户显示的每个像素,您计算出它与光线的距离以及它将出现在深度图中的位置,然后检查它是否比深度图中留下的像素距光线更近或更远。因此,通过在精度问题上花费一些精力,您可以检查每个像素是否从光中“可见”,从而检查它是否被点亮。

渲染到 CAEAGLLayer 支持的视图是生成 OpenGL 输出的一种方式,UIKit 知道如何将其合成到屏幕上。因此,iOS 允许您在普通 Cocoa Touch 显示器的层次结构中向用户呈现最终的 OpenGL 输出。

If you render to a texture then the image you've rendered is processed in such a manner as to make it immediately usable as a texture, which in practice usually means with negligible or zero effort from the CPU. You normally render to texture as part of a more complicated rendering pipeline.

Shadow buffers are the most obvious example — they're one way of rendering shadows. You position the camera where the light source would be and render the scene from there so that the final depth information ends up in a texture. You don't show that to the user. For each pixel you do intend to show to the user you work out its distance from the light and where it would appear in the depth map, then check if it is closer or further from the light than whatever was left in the depth map. Hence, with some effort expended on precision issues, you check whether each pixel is 'visible' from the light and hence whether it is lit.

Rendering to a CAEAGLLayer-backed view is a way of producing OpenGL output that UIKit knows how to composite to the screen. So it's the means by which iOS allows you to present your final OpenGL output to the user, within the hierarchy of a normal Cocoa Touch display.

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