Framebuffer Operations(帧缓冲区的操作)

周一到周五,每天一篇,北京时间早上7点准时更新~,中英文对照,一边学编程一边弹吉他,做一个奇葩码农!

The framebuffer is the last stage of the OpenGL graphics pipeline(帧缓冲区是OpenGL图形管线的最后一个阶段). It can represent the visible content of the screen and a number of additional regions of memory that are used to store per-pixel values other than color(它可以表示屏幕可见区域的部分自己一些存储里与这些像素有关的其他非颜色信息的内存块). On most platforms, this means the window you see on your desktop(在大多数平台上,帧缓冲区指代的是窗口) (or possibly the whole screen if your application covers it), which is owned by the operating system (这个操作系统所管理的)(or windowing system to be more precise). The framebuffer provided by the windowing system is known as the default framebuffer, but it is possible to provide your own if you wish to do things like render into off-screen areas(操作系统所管理的帧缓冲区我们称之为默认的缓冲区,你也可以创建你自己的缓冲区用于离线渲染). The state held by the framebuffer includes information such as where the data produced by your fragment shader should be written, (帧缓冲区拥有的信息包括由你的fragment shader产生的数据应该写到哪里去)what the format of that data should be, and so on(被写入的数据应该是什么等等这类的信息). This state is stored in a framebuffer object(这些信息都存储在帧缓冲区里). Also considered part of the framebuffer, but not stored per framebuffer object, is the pixel operation state(像素操作阶段,帧缓冲区可能只有部分进行这个操作,而不是整个帧缓冲区)

Pixel Operations(像素操作)

After the fragment shader has produced an output(在fragment shader产生了输出之后), several things may happen to the fragment before it is written to the window(在像素被写到窗口上之前,会发生很多个操作), such as a determination of whether it even belongs in the window(比如判断该像素是否属于这个窗口的问题). Each of these things may be turned on or off by your application(每一个操作都可以被你开启和关闭). The first thing that could happen is the scissor test, which tests your fragment against a rectangle that you can define(第一个事情就是scissor测试,你可以定义一个矩形来测试的你像素). If it’s inside the rectangle, then it will be processed further; if it’s outside, it will be thrown away(如果这个像素在矩形里面,那么这个矩形就会被传输给下一个阶段进行处理,否则会被丢弃)

Next comes the stencil test. This compares a reference value provided by your application with the contents of the stencil buffer, which stores a single4 value per pixel(下一个阶段就是蒙版测试,它会根据你蒙版缓冲区里的值来进行处理). The content of the stencil buffer has no particular semantic meaning and can be used for any purpose(蒙版测试是一个通用的操作,可以被用于任何事情)

After the stencil test has been performed, the depth test is performed. The depth test is an operation that compares the fragment’s z coordinate against the contents of the depth buffer(蒙版测试之后就轮到深度测试了,深度测试测试的是你当前绘制的像素是否被遮挡的问题). The depth buffer is a region of memory that, like the stencil buffer, is part of the framebuffer with enough space for a single value for each pixel; it contains the depth (which is related to distance from the viewer) of each pixel(深度缓冲器存储着每个像素对应的深度信息)

Normally, the values in the depth buffer range from 0 to 1, with 0 being the closest possible point in the depth buffer and 1 being the furthest possible point in the depth buffer(一般来说,深度的信息范围是0~1,0表示离你最近的深度,1表示离你最远的深度). To determine whether a fragment is closer than other fragments that have already been rendered in the same place(为了判断某一个像素比同一个位置的其他像素离你是否更近), OpenGL can compare the z component of the fragment’s window-space coordinate against the value already in the depth buffer(OpenGL会拿当前像素的z的值与深度缓冲区上的z的值进行比较). If this value is less than what’s already there, then the fragment is visible. The sense of this test can also be changed(如果当前像素的深度值比深度缓冲区上的z的值小,则该像素可见,否则不可见). For example, you can ask OpenGL to let fragments through that have a z coordinate that is greater than, equal to, or not equal to the content of the depth buffer(比如你当前渲染的像素的z的值比深度缓冲区里的对应的z的值大,那么当前像素则不会被写入当前的颜色缓冲区里去). The result of the depth test also affects what OpenGL does to the stencil buffer(深度测试的结果也会影响到蒙版缓冲区里的内容).

Next, the fragment’s color is sent to either the blending or logical operation stage(接下来像素颜色被发送给混合或者是alpha逻辑操作的阶段), depending on whether the framebuffer is considered to store floating-point, normalized, or integer values(这取决于帧缓冲区里存储的数据是浮点数据还是单位化的数据还是整数). If the content of the framebuffer is either floating-point or normalized integer values, then blending is applied(如果帧缓冲区的数据格式是浮点数或者是单位化的整数,那么下一个阶段就是混合了). Blending is a highly configurable stage in OpenGL and will be covered in detail in its own section.(混合是一个非常具备可操作性的阶段,所以我们将在它自己的章节详细展开讲解)

In short, OpenGL is capable of using a wide range of functions that take components of the output of your fragment shader and of the current content of the framebuffer and calculate new values that are written back to the framebuffer(简单来说,OpenGL可以通过一大堆函数来操作你fragment shader输出的内容与帧缓冲区的内容,并且计算出新的数据最终写回帧缓冲区). If the framebuffer contains unnormalized integer values(如果帧缓冲区里是没有单位化的整型数据), then logical operations such as logical AND, OR, and XOR can be applied to the output of your shader and the value currently in the framebuffer to produce a new value that will be written back into the framebuffer(那么下一个处理阶段就是逻辑操作了,使用and、or、XOR来操作当前像素与帧缓冲区里的数据,并最终将结果写回帧缓冲区)

本日的翻译就到这里,明天见,拜拜~~

第一时间获取最新桥段,请关注东汉书院以及图形之心公众号

东汉书院,等你来玩哦

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: OpenGL ES(Open Graphics Library for Embedded Systems)是一种软件接口,用于在嵌入式系统(如手机,平板电脑)上进行2D和3D图形绘制。 缓冲区framebuffer)是OpenGL ES中的一个图形缓冲区,用于存储图形绘制的输出。它由多个颜色缓冲区(color buffer)和深度缓冲区(depth buffer)组成。当图形绘制完成后,缓冲区中的图像将被显示在屏幕上。 在OpenGL ES中,缓冲区可以用来实现许多不同的效果,包括双缓冲(double buffering)、多重采样(multisampling)和屏幕空间反射(screen space reflections)。 ### 回答2: OpenGL ES是一种在移动设备和嵌入式系统上使用的图形库,它提供了一种可编程的方式来渲染2D和3D图形。在OpenGL ES中,缓冲区是一个用于存储渲染输出的内存区域。 缓冲区是一个用于存储图像数据的固定大小的缓冲区。在渲染过程中,OpenGL ES会将渲染输出存储到缓冲区中。缓冲区可以看作是一个像素数组,每个像素都包含了颜色值和其他可能的信息,如深度、模板等。通过使用缓冲区,我们可以进行离屏渲染、后期处理和图像效果的操作。 在OpenGL ES中,我们可以创建多个缓冲区并切换它们来实现不同的渲染效果。通常情况下,我们会创建一个前向渲染的缓冲区,用于将渲染结果直接显示在屏幕上。同时,我们也可以创建一个后向渲染的缓冲区,用于存储渲染结果以便后续处理。 使用缓冲区可以实现一些常见的图像效果,如屏幕后处理、多重采样抗锯齿(MSAA)、阴影渲染等。通过在缓冲区上执行多个渲染通道,我们可以将不同的渲染效果叠加在一起,创建出更加复杂和逼真的图像效果。 需要注意的是,缓冲区的大小和格式应该与设备的显示屏幕大小和格式保持一致,以确保渲染结果可以正确地显示出来。同时,由于缓冲区占用了系统内存,我们在使用完之后需要及时释放它,以避免内存泄漏和性能问题。 总之,缓冲区在OpenGL ES中扮演着重要的角色,它提供了一种存储渲染输出的机制,并且可以通过多个渲染通道实现各种图像效果。通过合理使用缓冲区,我们可以创建出更加逼真和吸引人的图形效果。 ### 回答3: OpenGL ES的缓冲区是用于渲染图形的重要概念。它是一个内存区域,用于存储渲染的结果,并将其发送到显示设备以显示在屏幕上。 缓冲区由颜色附件和可选的深度和模板附件组成。颜色附件用于存储渲染的颜色值,而深度和模板附件分别用于存储深度和模板信息。 在渲染过程中,我们可以在缓冲区中绘制图形。首先,我们将缓冲区设置为当前绘制目标,然后使用OpenGL ES提供的各种绘制命令来绘制图形。在绘制完成后,渲染的结果将存储在缓冲区中。 一旦渲染完成,我们可以选择将缓冲区中的内容发送到显示设备并显示在屏幕上。这通常通过将缓冲区绑定到纹理对象或渲染缓冲对象来完成。然后,我们可以将纹理对象或渲染缓冲对象作为图形渲染的输入来进行后续处理或者直接在屏幕上显示。 缓冲区提供了一个灵活和高效的方式来进行图形渲染。通过使用缓冲区,我们可以实现各种视觉效果,例如离屏渲染、后期处理和屏幕抖动等。此外,缓冲区还允许我们进行多重渲染目标,即同时将结果存储在多个颜色附件中,从而实现更复杂的渲染效果。 总而言之,OpenGL ES的缓冲区是一个用于存储渲染结果的内存区域,它提供了灵活和高效的方式来进行图形渲染,并可以将结果发送到显示设备以显示在屏幕上。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值