Chapter 1 Introdoution

来源:互联网 发布:java异常声明 编辑:程序博客网 时间:2024/06/03 18:20

      终于开始了cg语言的学习,在网上也没找到什么好的中文教程,找了本Nv公司的英文书, The Cg Tutorial。接下来记录下读书笔记。

第一章,简介

      这一章从四个方面来大概的介绍了cg语言


 

     1、cg语言究竟是什么样的语言?

     源于C语言,但和c、c++、java语言不同的是,它专为使用GPU运算而设计的语言,不能用于独立实现一些业务或者功能软件。它支持目前两大3D开发接口:OpenGL和Direct3D。基于此,就有了跨平台的优点,支持Windows, Linux, Macintosh OS X, and  console platforms such as the Xbox 。

   

 


     2、介绍Vertices, Fragments, the Graphics Pipeline的概念

      Vertices,顶点。获取图元顶点信息是绘制场景的起点。

      Fragments,首先应该提到Pixel的概念。Pixel的概念好理解,A pixel represents the contents of the frame buffer at a   specific location, such as the color, depth, and any other values associated with that location.

      A fragment is the state required potentially to update a particular pixel。You can think of a fragment as a "potential pixel." If a fragment passes the various rasterization tests (in the raster operations stage, which is described shortly), the fragment updates a pixel in the frame buffer.(标红的词需要特别注意

     fragment指,在光栅化阶段,即将投影到backbuffer上像素点的位置,还没投影到的潜在的像素描述。如果通过深度测试、模版测试后,可以将值写入backbuffer的对应像素值。这也是为什么一直说它potential的原因。如下图描述加深理解:

 

   光栅化阶段中,打满了无数的小网格的为fragments

   the Graphics Pipeline  图像渲染管道,理解它就一张图足矣。

Cg语言关注的是 Programmable Vertex Processor  和 Programmable Fragment Processor

 


 

     3、Cg的发展史

         首先要提的是,Cg和微软的HLSL语言是同一种语言。Cg语言是有Nvidia和MS联合开发的,MS抽出Direct3D的部分作为DirectX 9的多媒体框架的一部分。

         发展史主要分为:

         Shader Tree    Based on Rob Cook's Original SIGGRAPH Paper

         基于Shader Tree的灵感,产生了非交互的渲染语言( Noninteractive Shading Language) ,最著名的是The RenderMan Shading Language

        虽然人们提出在硬件渲染中,将过程分解很多独立的子过程。90年代中期,北卡大学那些鬼们开始对programmable graphics hardware进行研究,并且发明了一个新的programmable graphics hardware architecture, called PixelFlow。问题是,关键的问题是,这个PixelFlow架构太昂贵,最终没能商业化。。。。真是一群死鬼...

         最终斯坦福的研究院们发明的Stanford Real-Time Shading Language (RTSL),估计这也就是传说中的渲染管道的雏形....  能够编译后,为OpenGl的rendering passes所用。Nvidia和斯坦福研究院联合下,开发这种commercial-quality hardware-amenable
shading language。2001年,Bill Mark加入NV公司,参与由NV和MS联合开发和定制这种渲染语言,它也就是Cg。

 


    4、Cg的环境和相关工具 

     工具就不用多说了,用用就知道了。

    The CgFX Toolkit  能够在nv官网上下载。

    唯一需要注意的是一个3D应用如果使用Cg,如下图所示:

 

 

结束语: 完了~!

原创粉丝点击