CgTutorial-Chapter1-2(1) the cg tutorial 中文

1.2顶点、片段和图形流水线

1.2 Vertices, Fragments, and the GraphicsPipeline

为了把Cg放在一个合适的位置,你需要理解GPU是如何渲染图像的。这个部分将解释图形硬件是如何发展的,然后将探索当今的图形硬件处理器的渲染流水线。

To put C g into its proper context, you need tounderstand how GPUs render images. This section explains howgraphics hardware is evolving and then explores the modern graphicshardware-rendering pipeline.

1.2.1 计算机图形硬件的发展历史

计算机图形硬件正在以不可思议的速度前进着。如图1-2所示,一共有三个力量驱使这种创新的步伐。首先,半导体工业自身每18个月就使一个微芯片上得晶体管数目增加一倍。计算机能力则以这个在历史上被称为摩尔定律的固定加倍速度下发展着。这意味着更便宜和更快的计算机硬件,会成为我们这个时代的普通标准。

Computer graphics hardware is advancing atincredible rates. Three forces are driving this rapid paceof

innovation, as shown in Figure 1-2. First, thesemiconductor industry has committed itself to doublingthe

number of transistors (the basic unit of computerhardware) that fit on a microchip every 18 months. This

constant redoubling of computer power,historically known as Moore's Law, means cheaper andfaster

computer hardware, and is the norm for ourage.


Figure 1-2 Forces Driving Graphics HardwareInnovation

第二种推动计算机图形硬件的原因是:模拟我们周围的世界需要大量的计算。人的眼睛和大脑以一种令人惊讶的速度敏锐地接触、观察和理解三维世界的图像。我们永远不可能使得计算机图形成为现实的替代物。现实世界是在是太真实了。计算机图形的实践者们还是勇敢地站起来接受挑战。幸运地是,生成图像是一个“使人为难的并行问题”。我们所谓的“使人为难的并行问题”是指,图形硬件的设计者们可以把创造真实世界这个问题重复地分解成许多比较小和比较容易解决的问题。然后,硬件工程师们就可以并行地安排大量的晶体管来执行所有的不同工作。

The second force is the vast amount of computationrequired to simulate the world around us. Our eyes consume and ourbrains comprehend images of our 3D world at an astounding rate andwith startling acuity. We are unlikely ever to reach a point wherecomputer graphics becomes a substitute for reality. Reality is justtoo real. Undaunted, computer graphics practitioners continue torise to the challenge. Fortunately, generating images is anembarrassingly parallel problem. What we mean by "embarrassinglyparallel" is that graphics hardware designers can repeatedly splitup the problem of creating realistic images into more chunks ofwork that are smaller and easier to tackle. Then hardware engineerscan arrange, in parallel, the ever-greater number of transistorsavailable to execute all these various chunks of work.

我们所说的第三种力量是,我们期望能够体验到更加真实的模拟和娱乐感受。这种力量把持续增长的计算机硬件资源和模拟更加真实的虚拟现实任务“连接起来”。

Our third force is the sustained desire we allhave to be stimulated and entertained visually. This is the forcethat "connects" the source of our continued redoubling of computerhardware resources to the task of approximating visual reality evermore realistically than before.

正如图1-2所显示的那样,这些敏锐地观察使我们有信心预言计算机图形硬件的处理速度将会变得更为迅速。这些创新使我们拥有更好的交互性与令人炫目的二维体验拥有更强烈的欲望。而满足这些需求是激发我们开发Cg预言的动力。

As Figure 1-2 illustrates, these insights let usconfidently predict that computer graphics hardware is going to getmuch faster. These innovations whet our collective appetite formore interactive and compelling 3D experiences. Satisfying thisdemand is what motivated the development of the C glanguage.


1.2.2 四代计算机图形硬件

================================================================

历史的东西比较多,以后有空了在看好了。
有兴趣的同学去自己找找吧,个人感觉对Cg学习没什么帮助。

==================================================================

1.2.3 图形硬件流水线

1.2.3 The Graphics HardwarePipeline

流水线是一系列可以并行和按照固定顺序操作的阶段。每个阶段都从它的前一阶段接受输入,然后把输出发送给随后的阶段。就像同时制造不同阶段不同汽车的汽车装配线一样。传统的图形硬件流水线以流水的方式处理大量的顶点、片段和几何图形。

A pipeline is a sequence of stages operating in parallel andin a fixed order. Each stage receives its input from the priorstage and sends its output to the subsequent stage. Like anassembly line where dozens of automobiles are manufactured at thesame time, with each automobile at a different stage of the line, aconventional graphics hardware pipeline processes a multitude ofvertices, geometric primitives, and

fragments in a pipelined fashion.

图1-3显示了当今GPU所使用的图形硬件流水线。3D应用程序传给GPU一系列由顶点组成不同的几何图元:典型的多边形、线段和点。正如图1-4所示,有许多方法来制定几何图元。

Figure 1-3 shows the graphics hardware pipelineused by today's GPUs. The 3D application sends the GPU a sequenceof vertices batched into geometric primitives: typically polygons,lines, and points. As shown in Figure 1-4, there are many ways tospecify geometric primitives.


Figure 1-3 The Graphics Hardware Pipeline

Figure 1-4 Types of GeometricPrimitives

每个顶点除了有位置信息外,还有一些其他属性,例如颜色、间色(反射),一个或多个纹理坐标集合一个法向量(normal vector)。法向量指示了物体表面在改顶点的方向,他是专门用来计算光照的。

Every vertex has a position but also usually hasseveral other attributes such as a color, a secondary (orspecular) color, one or multiple texture coordinate sets,and a normal vector. The normal vector indicates what direction thesurface faces at the vertex, and is typically used in lightingcalculations.

1.2.3.1 顶点变换

Vertex Transformation

顶点变换(Vertextransformation)是图形硬件流水线中第一个处理阶段。顶点变换在每个顶点上执行一系列数学操作。这些操作包括把顶点位置变换到屏幕位置以供光栅器使用、为贴图产生纹理坐标、以及决定顶点颜色的光照运算。我们将在后续的几章解释这些任务中的大部分内容。

Vertex transformation is the first processing stage in the graphicshardware pipeline. Vertex transformation performs a sequence ofmath operations on each vertex. These operations includetransforming the vertex position into a screen position for use bythe rasterizer, generating texture coordinates for texturing, andlighting the vertex to determine its color. We will explain many ofthese tasks in subsequent chapters.

1.2.3.2 图元装配和光栅化

Primitive Assembly andRasterization

经过变换的顶点数据流按照顺序被送到下一个被称为图元装配和光栅化的阶段。首先,在图元装配阶段根据伴随顶点序列的几何图元分类信息把顶点转配成几何图元。这将产生一系列的三角形,线段和点。这些图元需要经过剪裁到可视平截体(view frustum)(一个三维空间的可见矩形区域)和任何应用程序指定的有效剪裁平面。光栅器还可以根据空间多边形的朝向丢弃一些多边形。这个过程被称为挑选(culling)。

The transformed vertices flow in sequence to thenext stage, called primitive assembly andrasterization. First, the primitive assembly step assemblesvertices into geometric primitives based on thegeometric

primitive batching information that accompaniesthe sequence of vertices. This results in a sequence of triangles,lines, or points. These primitives may require clipping tothe view frustum (the view's visible region of 3D space), as wellas any enabled application-specified clip planes. The rasterizermay also discard polygons based on whether they face forward orbackward. This process is known as culling.

经过剪裁和挑选的多边形必须被光栅化。光栅化是一个决定哪些像素被几何图元覆盖的过程。多边形、线段和点根据每种图元指定的规则分别被光栅化。光栅化的结果是像素位置的集合和片段的集合。当光栅化后,一个图元拥有的顶点数目和产生的片段之间没有任何关系。例如,如果一个由一个顶点组成的三角形可以占据整个屏幕,则需要生成上百万的片段!

Polygons that survive these clipping and cullingsteps must be rasterized. Rasterization is the process ofdetermining the set of pixels covered by a geometric primitive.Polygons, lines, and points are each rasterized according to therules specified for each type of primitive. The results ofrasterization are a set of pixel locations as well as a set offragments. There is no relationship between the number of verticesa primitive has and the number of fragments that are generated whenit is rasterized. For example, a triangle made up of just threevertices could take up the entire screen, and therefore generatemillions of fragments!

我们在前面已经告诉过你可以把片段看成一个像素。但是,现在片段和像素之间的区别变得非常重要了。术语“像素”是图像元素的简称。一个像素代表帧缓存中的某个指定位置的内容。例如颜色、深度和其他与这个位置相关联的值。一个片段则是更新一个特定像素所需的一个潜在必要的状态。

Earlier, we told you to think of a fragment as apixel if you did not know precisely what a fragment was. At thispoint, however, the distinction between a fragment and a pixelbecomes important. The term pixel is short for "picture element." A pixel representsthe contents of the frame buffer at a specific location, such asthe color, depth, and any other values associated with thatlocation. A fragment is the state required potentially to update aparticular pixel.

所以,术语“片段”是用来描述因光栅化而把每个几何图元(例如三角形)所覆盖的像素分解成像素大小的片段。一个片段有一个与之关联的像素位置、深度值和经过插值的参数,例如颜色、间色(反射)和一个或多个纹理坐标集。这些不同的插值是得自变换过的顶点,这些顶点组成了某个用来生成片段的几何图元。你可以把片段看成是潜在的像素,如果一个片段通过光栅化测试(光栅化测试将在光栅操作阶段被简单介绍),这个片段将被用于更新帧缓存中得像素。

and one or more texture coordinate sets. Thesevarious interpolated parameters are derived from the transformedvertices that make up the particular geometric primitive used togenerate the fragments. You can think of a fragment as a "potentialpixel." If a fragment passes the various rasterization tests (inthe raster operations stage, which is described shortly), thefragment updates a pixel in the frame buffer.

1.2.3.3 插值、贴图和着色

Interpolation, Texturing, andColoring

当一个图元被光栅化为零个或多个片段的时候,插值、贴图和着色阶段就在片段属性需要的时刻插值,执行一系列的贴图和数学操作,然后为每个片段确定一个最终的颜色。这个阶段还会确定一个新的深度,或者为了避免更新帧缓存的对应像素而丢弃这个片段。这个阶段允许丢弃片段信息,因此这个阶段可能不会对片段着色。

Once a primitive is rasterized into a collectionof zero or more fragments, the interpolation, texturing, and coloringstage interpolates the fragment parameters asnecessary, performs a sequence of texturing and math operations,and determines a final color for each fragment. In addition todetermining the fragment's final color, this stage may alsodetermine a new depth or may even discard the fragment to avoidupdating the frame buffer's corresponding pixel. Allowing for thepossibility that the stage may discard a fragment, this stage emitsone or zero colored fragments for every input fragment itreceives.

1.2.3.4 光栅操作

Raster Operations

光栅操作阶段是在帧缓存更新前,执行一系列针对每个片段的操作的最后一个阶段。这些操作时OpenGL和Direct3D的一个标准组成部分。在这个阶段,隐藏面通过一个被称为深度测试的过程而被隐藏。其他一些效果,例如混合和基于模板的阴影也发生在这个阶段。

The raster operations stage performs a final sequence of per-fragmentoperations immediately before updating the frame buffer. Theseoperations are a standard part of OpenGL and Direct3D. During thisstage, hidden surfaces are eliminated through a process knownas depth testing. Other effects, such as blending andstencil-based shadowing, also occur during this stage.

光栅操作阶段将根据许多测试结果来检查每个片段,这些测试包括剪切、alpha、模板和深度等测试。这些测试设计了片段最后的颜色和深度,像素的位置和一些像素值(例如像素的深度值和模板值)。如果任何一项测试失败了,片段就会在这个阶段被丢弃,而更新像素的颜色值(虽然一个模板写入操作依旧发生)。通过深度测试就可以用片段的深度值代替像素的深度值了。在这些测试之后,一个混合操作将把片段的最后颜色和对应像素的颜色结合在一起。最后一个帧缓存写操作用混合的颜色代替像素的颜色,图1-5显示了这一系列的操作。

The raster operations stage checks each fragmentbased on a number of tests, including the scissor, alpha, stencil,and depth tests. These tests involve the fragment's final color ordepth, the pixel location, and per-pixel values such as the depthvalue and stencil value of the pixel. If any test fails, this stagediscards the fragment without updating the pixel's color value(though a stencil write operation may occur). Passing the depthtest may replace the pixel's depth value with the fragment's depth.After the tests, a blending operation combines the final color ofthe fragment with the corresponding pixel's color value. Finally, aframe buffer write operation replaces the pixel's color with theblended color. Figure 1-5 shows this sequence ofoperations.

Figure 1-5 Standard OpenGL and Direct3D RasterOperations

图1-5显示了光栅操作阶段本身实际上也是一个流水线。实际上,所有以前介绍的阶段都可以被进一步分解成子阶段。

Figure 1-5 shows that the raster operations stageis actually itself a series of pipeline stages. In fact, all of thepreviously described stages can be broken down into substages aswell.

1.2.3.5 形象化图形流水线

Visualizing the GraphicsPipeline

图1-6描写了图形流水线的各个阶段,在本图中,两个三角形被光栅化。整个过程从顶点的变换和着色开始。下一步,图元装配阶段从顶点创建三角形,如虚线所示。之后,光栅用片段填充三角形。最后从顶点得到的值被用来插值,然后用于贴图和着色,注意仅仅从几个顶点就产生了多个片段。

Figure 1-6 depicts the stages of the graphicspipeline. In the figure, two triangles are rasterized. The processstarts with the transformation and coloring of vertices. Next, theprimitive assembly step creates triangles from the vertices, as thedotted lines indicate. After this, the rasterizer "fills in" thetriangles with fragments. Finally, the register values from thevertices are interpolated and used for texturing and coloring.Notice that many fragments are generated from just a fewvertices.

Figure 1-6 Visualizing the Graphics Pipeline

  

爱华网本文地址 » http://www.413yy.cn/a/25101011/58136.html

更多阅读

杨家将外传2.1攻略 精 杨家将外传1.9攻略

  杨家将外传是指基于魔兽争霸3:冰封王座(由暴雪娱乐公司出品)的多人以通关为目的的自定义地图,支持1-8个人同时连线游戏。截止到08年9月,已正式发布的地图名称有杨家将外传(V1.8、V1.9、V2.0、V2.1等)多个不同类型和挑战难度的地图版本

蓝牙4.0版和3.0版和2.1版有什么区别,怎么选 蓝牙3.0和4.0 鼠标

蓝牙4.0版和3.0版和2.1版有什么区别,怎么选——简介 蓝牙目前的普及程度已不亚于手机,比如蓝牙耳机、蓝牙音箱,支持蓝牙更是智能手机的入门标配,但是目前市场上蓝牙版本众多,那么我们在实际购买时怎么选购呢?下面介绍一下他们的区别以及怎

iPod touch二代固件4.2.1完美越狱 ipodtouch2 4.2.1越狱

iPod touch二代固件4.2.1完美越狱。(Windows 版)iPod touch二代固件4.2.1完美越狱——准备工作iPod touch二代固件4.2.1完美越狱 1、电脑上:iPod touch二代固件4.2.1完美越狱 2、下载红雪RedSn0w 0.9.6 b4。iPod touch二代固件4.2.1完

2.1.2指数函数及其性质1 现场评课稿 指数函数及其性质

2.1.2指数函数及其性质(1)现场评课稿翁垟高级中学 郑月央听了新教师金老师的课,同时对比老教师张琴微老师的课,我感触很深,也学到了很多。两位老师的共同特点是用多媒体为辅助手段,采用启发式和课堂讨论的方法,以教师为主导学生为主体展

声明:《CgTutorial-Chapter1-2(1) the cg tutorial 中文》为网友琼窗梦回分享!如侵犯到您的合法权益请联系我们删除