OpenGL Rendering Pipeline

来源:互联网 发布:js 二维数组定义 编辑:程序博客网 时间:2024/05/15 01:33

 

Vertex Operation顶点操作(平移、旋转、伸缩、光照)

Each vertex and normal coordinates are transformed by GL_MODELVIEW matrix 

(from object coordinates to eye coordinates). Also, if lighting is enabled, the lighting 

calculation per vertex is performed using the transformed vertex and normal data.

 This lighting calculation updates new color of the vertex.

 

Primitive Assembly图元装配(将基本的几何图元装配)

After vertex operation, the primitives (point, line, and polygon) are transformed once 

again by projection matrix(3D转换成2D) then clipped by viewing volume clipping 

planes(通过裁剪面进行裁剪)from eye coordinates to clip coordinates. After that,

 perspective division by w occurs and viewport transform is applied in order to map

 3D scene to window space coordinates. Last thing to do in Primitive Assembly is culling 

test if culling is enabled. 

以上两步可以细节如下:

Geometric data such as vertex positions and normal vectors are transformed via Vertex 

Operation and Primitive Assembly  operation in OpenGL pipeline before raterization process.

 

物体坐标系-人眼坐标系-裁剪坐标系-标准设备坐标系--窗口坐标系

物体坐标系-人眼坐标系(物体坐标系-世界坐标系-人眼坐标系):平移、旋转、伸缩、光照

人眼坐标系-裁剪坐标系:将3D投影至2D并通过裁剪面裁剪至去头视锥体

裁剪坐标系-标准设备坐标系:对坐标值进行标准化(-1,1)

标准设备坐标系--窗口坐标系:对标准化的坐标进行适应屏幕像素的调整

 

Display List

Display list is a group of OpenGL commands that have been stored (compiled) for later execution. 

All data, geometry (vertex) and pixel data, can be stored in a display list. It may improve performance

 since commands and data are cached in a display list. 

Display List相当于数据和命令的缓存,但是用的场景是固定的静态数据或者OpenGL命令(没有返回值)

比如静态画面的数据和用于生成此静态画面的命令。对于动态的数据或者OpenGL命令,用VBO要更好一点。

 

Pixel Transfer Operation

After the pixels from client's memory are unpacked(read), the data are performed scaling, bias, 

mapping and clamping. These operations are called Pixel Transfer Operation. The transferred 

data are either stored in texture memory or  rasterized directly to fragments. 

 

Texture Memory

Texture images are loaded into texture memory to be applied onto geometric objects. 
 

Raterization

Rasterization is the conversion of both geometric and pixel data into fragment. Fragments are a

 rectangular array containing color, depth, line width, point size and antialiasing calculations 

(GL_POINT_SMOOTH, GL_LINE_SMOOTH, GL_POLYGON_SMOOTH). If shading mode is GL_FILL,

 then the interior pixels (area) of polygon will be filled at this stage. Each fragment corresponds to

 a pixel in the frame buffer. 

 

Fragment Operation

It is the last process to convert fragments to pixels onto frame buffer. The first process in this stage

 is texel generation; A texture element is generated from texture memory and it is applied to the each

 fragment. Then fog calculations are applied. After that, there are several fragment tests follow in order; 

Scissor Test ⇒ Alpha Test ⇒ Stencil Test ⇒ Depth Test. Finally, blending, dithering, logical operation 

and masking by bitmask are performed and actual pixel  data are stored in frame buffer. 

 

Feedback

OpenGL can return most of current states and information through glGet*() and glIsEnabled() commands. Further more, you can read a rectangular area of pixel data from 

frame buffer using glReadPixels(), and get fully transformed vertex data using glRenderMode

(GL_FEEDBACK). glCopyPixels() does not  return pixel data to the specified system memory, but 

copy them back to the another frame buffer, for example, from front buffer to back buffer.

0 0
原创粉丝点击