FramebufferOperations(帧缓冲区的操作)-创新互联
周一到周五,每天一篇,北京时间早上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来操作当前像素与帧缓冲区里的数据,并最终将结果写回帧缓冲区)
本日的翻译就到这里,明天见,拜拜~~
第一时间获取最新桥段,请关注东汉书院以及图形之心公众号
东汉书院,等你来玩哦
另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
分享标题:FramebufferOperations(帧缓冲区的操作)-创新互联
URL地址:http://azwzsj.com/article/dhcchc.html