Framebuffer Operations(帧缓冲区的操作)
admin
2023-02-11 08:20:05
0

周一到周五,每天一篇,北京时间早上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来操作当前像素与帧缓冲区里的数据,并最终将结果写回帧缓冲区)

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

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

东汉书院,等你来玩哦

相关内容

热门资讯

德国总理:美国正在被伊朗羞辱 德国之声4月27日报道,德国总理默茨在访问一所学校时表示,在当前的持续冲突中,伊朗领导层正试图羞辱美...
理响中国|“长”歌以行,风云激... 光阴如梭,东方潮阔。这里是中国的长三角,世界的长三角。无论过去、现在还是未来,这片土地都因时代而生,...
白宫:特朗普及其国安团队开会讨... 新华社华盛顿4月27日电 美国白宫新闻秘书莱维特27日在记者会上证实,总统特朗普及其国家安全团队当天...
人民日报刊文:日本放开杀伤性武... 日本放开杀伤性武器出口推高地缘冲突风险(国际论坛)常思纯《人民日报》(2026年04月28日 第 0...
医疗保障法草案二审:明确生育保... 满足多样化健康保障需求本报记者 彭 波4月27日,医疗保障法草案二审稿提请十四届全国人大常委会第二十...
天津一景区发生自转旋翼机事故1... 澎湃新闻记者 吕新文中国民用航空华北地区管理局4月22日公布《豪客通航“10•1”天津长芦汉盐旅游区...
卡塔尔埃米尔与美国总统特朗普通... 当地时间24日,卡塔尔埃米尔塔米姆与美国总统特朗普通电话,重点就中东地区局势以及伊朗与美国谈判问题交...
男子30年前被扣押2859克黄... 澎湃新闻记者 王鑫家住辽宁省大连市的潘永嘉近日向澎湃新闻反映称,三十年前,他在大连周水子机场被盖州市...
商务部:取消反制欧盟两家金融机... 中华人民共和国商务部令二〇二六年 第1号鉴于欧盟已取消对中国两家金融机构的制裁措施,现公布《关于取消...
过去24小时共有5艘船只通过霍... 总台记者当地时间24日获悉,过去24小时内,共有5艘船只通过霍尔木兹海峡,其中包括一艘伊朗油轮。(总...