您好,登錄后才能下訂單哦!
周一到周五,每天一篇,北京時間早上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來操作當前像素與幀緩沖區里的數據,并最終將結果寫回幀緩沖區)
本日的翻譯就到這里,明天見,拜拜~~
第一時間獲取最新橋段,請關注東漢書院以及圖形之心公眾號
東漢書院,等你來玩哦
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。