入职作业总结(3.2)Rendering Pipeline

4 篇文章 0 订阅
3 篇文章 0 订阅

书上这么定义Rendering Pipeline:

Given a geometric description of a 3D scene with a positioned and oriented virtual camera, the rendering pipeline refers to the entire sequence of steps necessary to generate a 2D image based on what the virtual camera sees.

即:Rendering Pipeline指将3D空间中的物体依据一定的规则在2D屏幕上呈现出来的整个过程。

Rendering Pipeline由如图以下几个stage组成:(图暂时传不上来)


1.THE INPUT ASSEMBLER STAGE

The input assembler (IA) stage reads geometric data (vertices and indices) from memory and uses it to assemble geometric primitives (e.g., triangles, lines).

这个阶段,GPU根据指定的规则,将顶点(vertices)绘制成线条或者三角形(平面)这样的图元。使用void ID3D11DeviceContext::IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY Topology)函数设置特定的绘制规则(由D3D11_PRIMITIVE_TOPOLOGY枚举),常用的一般为D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST


2.THE VERTEX SHADER STAGE

After the primitives have been assembled, the vertices are fed into the vertex shader stage. The vertex shader can be thought of as a function that inputs a vertex and outputs a vertex. ; in fact, we can conceptually think of the following happening on the hardware:

for(UINT i = 0; i < numVertices; ++i)
   outputVertex[i] = VertexShader (inputVertex[i]);

这个阶段主要是绘制顶点。一开始奇怪为什么先用点画线和三角形再画点,后来理解这里画点跟前面的画线有所不同。由于顶点可能不仅仅只具有三维坐标的属性(可能还有光影等,取决于着色器),所以这一步有点像具体地画出某一点(再要准备呈现的图像buffer上),而前面一步类似于告诉GPU我要画这些图元(要画而未画,线和点都只具有无穷小的理想size)。

另外还有很重要的一点:第一步中的点是绘制在object space中的,因此这个阶段需要对这些点进行坐标转换(从object space到world space再到view space最后到projection space)。


3.THE TESSELLATION STAGES

Tessellation refers to subdividing the triangles of a mesh to add new triangles. These new triangles can then be offset into new positions to create finer mesh detail.

这个阶段可以通过把三角形进一步细分来绘制更精致的图形(如曲面)。这是个可选的图形优化。


4.THE GEOMETRY SHADER STAGE

没看懂。。短时间用不上,以后再说


5.THE RASTERIZATION STAGE

The main job of the rasterization stage is to compute pixel colors from the projected 3D triangles.

这个阶段主要是对图形进行计算色彩(具体上色交给PIXEL SHADER STAGE)。
既然是着色,DX也想办法在不需要的部分(摄像机看不到的部分)“偷懒”。Backface culling就是指这么一种技术:给平面上色时,平面的另一面(反面)就会被丢弃。
此外,(至少到目前理解到的知识看来)DX11平面的颜色是根据顶点的颜色对每个像素点进行插值得到的。 而perspective correct interpolation也是这个阶段需要考虑的。


6.THE PIXEL SHADER STAGE

Pixel shaders are programs we write that are executed on the GPU. A pixel shader is executed for each pixel fragment and uses the interpolated vertex attributes as input to compute a color. A pixel shader can be as simple as returning a constant color, to doing more complicated things like per-pixel lighting, reflections, and shadowing effects.

完成具体每个pixel着色的阶段。与上文说的一致,pixel的颜色是根据上个阶段插值得到的。这个阶段以此作为输入进行画pixel(有点类似之前画vertex一样,也是分了两个阶段)


7.THE OUTPUT MERGER STAGE

In this stage, some pixel fragments may be rejected (e.g., from the depth or stencil buffer tests). Pixel fragments that are not rejected are written to the back buffer. Blending is also done in this stage, where a pixel may be blended with the pixel currently on the back buffer instead of overriding it completely.

输出阶段,顺带对pixel做一些最终的调整。得到的pixels将被写入back buffer(等待被替换到前台作为新的一帧)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值