- 3D rendering pipeline (生成管道)
之所以成为管道,是因为整个过程像管道一样,前一个子过程的输出作为后一个子过程的输入。
管道分为四个部分:
1. 顶点处理 (vertex processor):输入为定点或图元(点,线,三角形,多边形,OpenGL支持十种基本图元),输出为经过转化的图元。
2. 光栅化 (rasterization):输入为上个阶段的输出,输出为片断。现代显示器都是基于光栅原理的,所谓“光栅”就是图像由像素组成,显示器在显示图像时按照从左到右从上往下的顺序一次从framebuffer中读取像素的颜色值,并将它显示出来。在此过程中,通过插值,将顶点与像素网格对齐,得到片断。像素是二维的,片断是三维的。
3. 片断处理 (fragment processor):输入为上个阶段的输出,对片断进行处理。
4. 输出整合 (output merging):输出的是片断进行整合处理后得到的具有颜色的像素,并显示。
对于以上四个部分,其中顶点处理和片断处理是可以通过编程 (vertex shader, fragment shader) 实现的,而光栅化和输出整合只能通过配置GPU实现。
顶点(vertex)具有四个主要属性:
1. 位置,用坐标表示;