3D Graphics Pipeline

作者为加深对Pipeline的理解,将其内容分为变换空间和渲染/光栅化两大部分。重点介绍了变换空间,包括不同变换空间在Pipeline中的先后顺序,如World Space到Screen Space等,还详细阐述了各空间的作用及特点,为图形引擎设计和优化打基础。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

注:看了许多关于Pipeline的资料,对于Pipeline也有一定的了解,但是总觉得还是模模糊糊的,似懂非懂的样子,对于Pipeline中各个阶段,仍然没有理清它们之间的相互关系,所以下决心写一些关于Pipeline的东西,写的过程也是一个加深理解的过程,我需要达到的目标是当我闭上眼睛的时候,我能很从容的讲出整个3D 图形流水线的工作过程。这样为以后的图形引擎设计,图形引擎优化打下坚实的基础。
闲话少说,现在就进入正题。根据我个人的理解,我准备把Pipeline的内容分成两个大的部分:
1.变换空间。
2.渲染/光栅化。

一.变换空间
空间变换的作用是将3D场景变换到2D的显示屏幕中的某个区域或者整个屏幕。不同的变换空间在Pipeline中的先后顺序是:
World Space->View Space->Culling->Clip Space(Optional)->Clipping->Screen Space->...
        |             |         |            |                              |
OPENGL  |--MODELVIEW--|-FRUSTUM-|-PROJECTION-|--------VIEWPORT--------------|
      |                                                                       |
      |------------------------------CPU--------------------------------------|
关于这几个变化空间详细的介绍,我在网上找到一篇很好的文章,我觉得介绍的非常清楚,所以把相关内容转贴到这里。这篇文章的出处是:
http://www.extremetech.com/article2/0,1558,464440,00.asp ,文章的版权归作者所有,我这里只是转贴:

Model Space: where each model is in its own coordinate system, whose origin is some point on the model, such as the right foot of a soccer player model. Also, the model will typically have a control point or "handle". To move the model, the 3D renderer only has to move the control point, because model space coordinates of the object remain constant relative to its control point. Additionally, by using that same "handle", the object can be rotated.
 

View Space (also called Camera Space): in this space, the view camera is positioned by the application (through the graphics API) at some point in the 3D world coordinate system, if it is being used. The world space coordinate system is then transformed (using matrix math that we'll explore later), such that the camera (your eye point) is now at the origin of the coordinate system, looking straight down the z-axis into the scene. If world space is bypassed, then the scene is transformed directly into view space, with the camera similarly placed at the origin and looking straight down the z-axis. Whether z values are increasing or decreasing as you move forward away from the camera into the scene is up to the programmer, but for now assume that z values are increasing as you look into the scene down the z-axis. Note that culling, back-face culling, and lighting operations can be done in view space. The view volume is actually created by a projection, which as the name suggests, "projects the scene" in front of the camera. In this sense, it's a kind of role reversal in that the camera now becomes a projector, and the scene's view volume is defined in relation to the camera. Think of the camera as a kind of holographic projector, but instead of projecting a 3D image into air, it instead projects the 3D scene "into" your monitor. The shape of this view volume is either rectangular (called a parallel projection), or pyramidal (called a perspective projection), and this latter volume is called a view frustum (also commonly called frustrum, though frustum is the more current designation).The view volume defines what the camera will see, but just as importantly, it defines what the camera won't see, and in so doing, many objects models and parts of the world can be discarded, sparing both 3D chip cycles and memory bandwidth. The frustum actually looks like an pyramid with its top cut off. The top of the inverted pyramid projection is closest to the camera's viewpoint and radiates outward. The top of the frustum is called the near (or front) clipping plane and the back is called the far (or back) clipping plane. The entire rendered 3D scene must fit between the near and far clipping planes, and also be bounded by the sides and top of the frustum. If triangles of the model (or parts of the world space) falls outside the frustum, they won't be processed. Similarly, if a triangle is partly inside and partly outside the frustrum the external portion will be clipped off at the frustum boundary, and thus the term clipping. Though the view space frustum has clipping planes, clipping is actually performed when the frustum is transformed to clip space.


Clip Space:
Similar to View Space, but the frustum is now "squished" into a unit cube, with the x and y coordinates normalized to a range between –1 and 1, and z is between 0 and 1, which simplifies clipping calculations. The "perspective divide" performs the normalization feat, by dividing all x, y, and z vertex coordinates by a special "w" value, which is a scaling factor that we'll soon discuss in more detail. The perspective divide makes nearer objects larger, and farther objects smaller as you would expect when viewing a scene in reality.
 

Screen Space: where the 3D image is converted into x and y 2D screen coordinates for 2D display. Note that z and w coordinates are still retained by the graphics systems for depth/Z-buffering (see Z-buffering section below) and back-face culling before the final render. Note that the conversion of the scene to pixels, called rasterization, has not yet occurred.Because so many of the conversions involved in transforming through these different spaces essentially are changing the frame of reference, it's easy to get confused. Part of what makes the 3D pipeline confusing is that there isn't one "definitive" way to perform all of these operations, since researchers and programmers have discovered different tricks and optimizations that work for them, and because there are often multiple viable ways to solve a given 3D/mathematical problem. But, in general, the space conversion process follows the order we just described.

暂时写的这里,未完待续。。。。。

参考文献:
1.
http://www.extremetech.com/article2/0,1558,464440,00.asp
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值