游戏开发论坛

 找回密码
 立即注册
搜索
楼主: windRain_ly

着色语言(Shader Language),以及HLSL VS GLSL VS CG

[复制链接]

5

主题

14

帖子

29

积分

注册会员

Rank: 2

积分
29
 楼主| 发表于 2009-11-24 18:26:00 | 显示全部楼层

Re: 着色语言(Shader Language),以及HLSL VS GLSL VS CG

还有一点,clayman兄说“不要把runtime和语言混为一谈,技术文章要求的就是精确”。我很同意你的说法。但首次指出,不是runtime,而是profile.

  但是也不能不说profile吧。文中比较 CG与HLSL是有目的的,正如经常有人比较JAVA和C++一样,同样有人比较C++和C,难道不能在描述JAVA的时候,说JAVA虚拟机吗?

  你知道你是否知道,使用CG语言时,需要指定进行编译的profile,这样才能真正的去适应DX和OPENGL。本质上说cg和HLSL是一对双胞胎,但并不是同一个人!

59

主题

984

帖子

1200

积分

金牌会员

Rank: 6Rank: 6

积分
1200
发表于 2009-11-24 20:01:00 | 显示全部楼层

Re: 着色语言(Shader Language),以及HLSL VS GLSL VS CG

究竟矛盾在什么地方?hlsl的移植性难道不差吗?cg难道不能被那两种API广泛支持吗?
-----------------------
我已经说了,只看代码,你是不能说这是hlsl还是cg的。你用dx中的函数加载,那么就能在dx中运行,用cg runtime加载那么就能在cg runtime所支持的所有平台运行,并且无论哪种runtime,最终shader的行为是一致的。

当初NVIDIA和MICRO为什么要创造CG语言?现在的GPU精粹一书中,为什么又使用CG语言?
-----------------------
cg/hlsl是nv和ms共同开发的,nv把它的实现叫cg,ms称为hlsl。两者无论语法还是语义都是一样的。使用hlsl就是cg

cg与HLSL在语法上很类似,但是底层则不相同
-----------------------
底层是一样的,都是编译为IL,然后运行时由driver编译为硬件代码。唯一的区别在于cg runtime会针对不同平台,生成不同代码。cg runtime分别包含了d3d 8/9/10的runtime和ogl的runtime,而dx自然只包含了前者。

但首次指出,不是runtime,而是profile
-----------------------
据我所知,nv的cg关于runtime 部分的文档名称就是《Cg Runtime Reference》。另外,profile和runtime也不是一个概念,profile是用来指定针对哪一级的硬件编译程序

JAVA和C++一样,同样有人比较C++和C,难道不能在描述JAVA的时候,说JAVA虚拟机吗?
-----------------------
同样的java代码运行在不同的虚拟机上,我们并不会认为这是不同的语言。cg/hlsl也一样,不能因为你用的编译器或者rumtime不同,就把他们认为是2种语言。

难道引用他们的说法有什么不对吗?
-----------------------
我并不反对应用别人的说法,但应用之前请是不是也应该判断一下内容正不正确呢?


不说了,再讨论好像也没多大意义

5

主题

14

帖子

29

积分

注册会员

Rank: 2

积分
29
 楼主| 发表于 2009-11-24 20:23:00 | 显示全部楼层

Re: 着色语言(Shader Language),以及HLSL VS GLSL VS CG

clayman
:我已经说了,只看代码,你是不能说这是hlsl还是cg的。你用dx中的函数加载,那么就能在dx中运行,用cg runtime加载那么就能在cg runtime所支持的所有平台运行,并且无论哪种runtime,最终shader的行为是一致的。
//
老实说:熟悉的人看代码是可以分辨hlsl和cg的。两者的语法虽然非常类似,但是并不是完全相同!这一点不知clayman是否承认?你说shader的行为是一致的,这就是在转移话题了,实际上无论是GLSL,还是HLSL都必须以硬件为基础,而实现的原理也是相同的,无非是驱动图形指令。但并其特性还是有所不同的。
----------------------------------------------------------------------------
cg/hlsl是nv和ms共同开发的,nv把它的实现叫cg,ms称为hlsl。两者无论语法还是语义都是一样的。使用hlsl就是cg
//
cg和hlsl是nv和ms共同研发的,但是请你注意,hlsl并不是两者共同研发的,而是微软专门为DX研发的。两者的语法类似,但只是类似,使用hlsl就是cg了吗?简直是荒谬之极,cg可以基于OPENGL使用,你在OSG开源引擎中使用hlsl试试?
-------------------------------------------------------------------------------------------

据我所知,nv的cg关于runtime 部分的文档名称就是《Cg Runtime Reference》。另外,profile和runtime也不是一个概念,profile是用来指定针对哪一级的硬件编译程序
//
请问你说的《Cg Runtime Reference》,是指《The cg Tutorial》书籍中的附录B吗?请你看看这个原文的是解释:
Appendix B. The Cg Runtime
B.1 What Is the Cg Runtime?

Cg programs supply programs for GPUs, but they need the support of an application to render images. To interface Cg programs with an application, you must do two things:

   1. Compile the programs for the appropriate profile. This step translates your Cg program into a form that is compatible with the 3D programming interface used by the application and the underlying hardware.
   2. Link the programs to the application program. This step allows the application to configure the program for execution, and to feed it varying and uniform parameters.

You can choose when you want to perform these operations. You can perform them at compile time, when the application program is compiled into an executable, or you can perform them at runtime, when the application is actually executed. The Cg runtime is a set of application programming interfaces (APIs) that allows an application to compile and link Cg programs at runtime.

runtime的概念和profile以及图形API是密切相关的。你说:profile是用来指定针对哪一级的硬件编译程序??
profile是针对哪一级硬件的?又是你的误解呀,小同志,请看原文:
A Cg profile defines a subset of the full Cg language that is supported on a particular hardware
platform or API(CgUsersManual 21 页)。
profile不光光之针对硬件的,还针对API。再次请教clayman兄,难道你觉得HLSL可以针对openGL的API做一个层次划分吗?

-------------------------------------------------------
我并不反对应用别人的说法,但应用之前请是不是也应该判断一下内容正不正确呢?
//
小同志,abelard_zheng兄不光贴出了国内在CSDN上的讨论,也贴出了OGRE官方论坛上的讨论,我很愚钝,不能判断真伪,所以请clayman兄判断一下下面的内容是否正确。不要再像上次一样动不动就说人家无知,你自己的论据在何处??OGRE上的论据如下,请您发表高论。
1:It is highly unlikely you will notice a performance difference between shader languages, so I would suggest you learn CG. The benefit of only having to write/maintain ONE shader for both DirectX and OpenGL is why CG is king in my book.

In the past (pre CG 2.0) there were some minor limitations on CG (running out of registers) which forced me to write a couple things in HLSL. But since 2.0 all those problems seem to have been solved. In the last year I have never had to write a single HLSL/GLSL shader. Bottom line, I cant think of any reason NOT to use CG.

2:If you decide to write native GLSL you'll find that not all video card drivers are equal when it comes to compiling the GLSL code down to assembly for the video card. The ATI cards especially have some annoying bugs and missing features. Some other cards just do not support very high revisions of the GLSL language (some Intel chipsets). You might end up managing shader code for each of these hardware configs, which is tedious and annoying.

The good news is that you can use Nvidia's Cg compiler to compile your GLSL code into code targeted for the hardware beforehand. The bad news is that Cg might not produce the most optimized code for complex effects. If you're going to do that though, and you're not going to even use OpenGL directly, just use Cg shader code!

Anyway, since you're asking these types of questions I hardly think you need to worry about which shader language is faster/more effective. Just use Cg.



227

主题

1793

帖子

1866

积分

金牌会员

Rank: 6Rank: 6

积分
1866
发表于 2009-11-24 20:27:00 | 显示全部楼层

Re: 着色语言(Shader Language),以及HLSL VS GLSL VS CG

回abelard_zheng
你看来是没仔细看我的代码
我是GLSL和Cg都用了
所有的shader都有两个实现版本
我是被逼无奈才这么做的

227

主题

1793

帖子

1866

积分

金牌会员

Rank: 6Rank: 6

积分
1866
发表于 2009-11-24 20:30:00 | 显示全部楼层

Re: 着色语言(Shader Language),以及HLSL VS GLSL VS CG

楼上几位不要光是高谈阔论
去找个AMD X系列/X1系列的显卡来写Cg试试看,绝对让你们崩溃

5

主题

14

帖子

29

积分

注册会员

Rank: 2

积分
29
 楼主| 发表于 2009-11-24 20:34:00 | 显示全部楼层

Re: 着色语言(Shader Language),以及HLSL VS GLSL VS CG

clayman,你也是对着色语言有研究的人。我也不和你顶牛了。其实有一点你说的对:
cg和HLSL是同一种语言!!!确实是这样的,只是底层的支持不同。

首先声明,我绝对不否认这一点。但是,你不能说我发的帖子就是混淆视听。帖子中明确的指出了两者是同样的语言:“HLSL和Cg其实是同一种语言(参见Cg教程_可编程实时图形权威指南29页的致谢部分)”。‘
并且人家作者已经给出了参考来源。然后再是阐述hlsl和CG的不同。这有什么不对吗?

两者语法相同,但使用方式并不相同,运用范围也不尽相同。为什么你就因为语言的语法、语义雷同,就不让别人说不同之处呢?

明明两者是有不同的地方的。你老说会混淆读者,可是你却有意忽略作者在文中已经点出的地方,我个人觉得你这种做法完全是意气之争。

5

主题

14

帖子

29

积分

注册会员

Rank: 2

积分
29
 楼主| 发表于 2009-11-24 20:44:00 | 显示全部楼层

Re: 着色语言(Shader Language),以及HLSL VS GLSL VS CG

回oz01,“AMD X系列/X1系列的显卡来写Cg试试看”,我确实没有在那样的显卡上写cg程序,不过我知道游戏中是绝不使用glsl的。我在ATI 3200系列下使用OSG做仿真项目,显卡型号应该没有记错,经常出现纹理全白的现象,而同样的显卡,在运行ogre的中带的着色程序就可以,我也正是因为这个原因才学习cg语言的。从工作角度来说,方便很多。

其实glsl和hlsl,cg都有各自的优点。现在NV不就是参与了opengl的制定吗?
凡事不是绝对的,上面的帖子也只是比较三者,对于现在学习着色语言的同学来说,如果从找工作方面考虑,我是建议学习hlsl和cg的。尤其是cg,学会了之后,就等于也通了hlsl。何乐而不为?

5

主题

14

帖子

29

积分

注册会员

Rank: 2

积分
29
 楼主| 发表于 2009-11-24 20:57:00 | 显示全部楼层

Re: 着色语言(Shader Language),以及HLSL VS GLSL VS CG

好了,这个帖子争了这么久是我想不到的。我和clayman兄争论的重点,我看并不在于学术上,而是在于语言描述上。可惜书不是我写的,不过我很欣赏国内有人写GPU和着色语言的书籍,所以贴上来给大家看看。论坛中确实有高手存在。至少通过这番争论,大家对glsl,hlsl和cg应该有一个比较了。

clayman兄老说这个引用不对,那个引用不对。好吧,我刚才又查了查,找到了一个比较正规的FAQ,国外的,贴出来给大家看看,这个应该比较客观。其实既然cg和HLSL是一样的语言,为什么不用跨平台性更好的呢?。网址是:http://www.fusionindustries.com/default.asp?page=cg-hlsl-faq

Cg and HLSL FAQ [Monday, June 02nd, 2003 - Alex]

Download Cg and HLSL FAQ as Text

                      A Cg & HLSL Shading Language FAQ
                            v0.003 June 6, 2003


This FAQ was created and is maintained by Alex (alexz@FusionIndustries.com).
Any comments, questions, additions and corrections are encouraged and
welcomed.

The latest version of this FAQ can be found at:
  www.FusionIndustries.com

  Japanese translation by Yukio Andoh - andoh AT opengl.com
  www.gimlay.org/~andoh/cg/faq/cg-hlsl-faq.html

This FAQ may be freely distributed or copied.

This FAQ is divided up into the following sections and questions:

1. The Cg/HLSL Language
2. Profiles
3. Semantics
4. Shader Entry Point (main())
5. Vertex Shaders
6. Fragment Shaders
7. Interfacing C/C++ and OpenGL with Cg
8. Miscellaneous
9. References
10. Bibliography
11. Change log

-------------------------------------------------
1. The Cg/HLSL Language
-------------------------------------------------
1.1:  What's the difference between nVidia's Cg and Microsoft's HLSL
      (High Level Shading Language)?

A:    Cg and HLSL are actually the same language! Cg/HLSL was co-developed
      by nVidia and Microsoft. They have different names for branding
      purposes. HLSL is part of Microsoft's DirectX API and only compiles
      into DirectX code, while Cg can compile to DirectX and OpenGL.
      
      In this FAQ, Cg and HLSL can be used interchangably.


-------------------------------------------------
2. Profiles
-------------------------------------------------
2.1:  When a shader is called, how does Cg know whether to treat it as a
      vertex or fragment shader?

A:    When a shader is loaded, one of the parameters allows the programmer
      to specify if it is a vertex or fragment shader. Also, the type of
      shader is specified when it is used.

      For example (using C/C++):

      ...
      CGprogram VProgram = cgCreateProgramFromFile(..."vertex_shader.cg"...);
      CGprofile profile = CG_PROFILE_VP20; // set globally
      ...
      void draw_loop()
      {
        cgGLBindProgram(VProgram);  // Binds shader to OpenGL calls
        cgGLEnableProfile(profile); // Tells Cg if it is a vertex
                                    // or fragment shader
          // your drawing code goes here
          // ie glBegin(...); glVertex3f(...); glEnd();
        cgGLDisableProfile(profile); // Unbinds shader
      }


2.2:  Which profile types are supported?

A:    This depends on what the Cg programming has been compiled for and the
      hardware the program is running on.
      
      The possible profiles are supported by the Cg compiler [1] (as of
      this writing):
      * DirectX Vertex Shader 2.x Profiles (vs_2_*)
      * DirectX Pixel Shader 2.x Profiles (ps_2_*)
      * OpenGL ARB Vertex Program Profile (arbvp1)
      * OpenGL ARB Fragment Program Profile (arbfp1)
      * OpenGL NV_vertex_program 2.0 Profile (vp30)
      * OpenGL NV_fragment_program Profile (fp30)
      * DirectX Vertex Shader 1.1 Profile (vs_1_1)
      * DirectX Pixel Shader 1.x Profiles (ps_1_*)
      * OpenGL NV_vertex_program 1.0 Profile (vp20)
      * OpenGL NV_texture_shader and NV_register_combiners Profile (fp20)

      The profiles in CG are named slightly differently. For example,
      the vp20 profile is called CG_PROFILE_VP20.

2.3:  Which profile is the best one to use?

A:    It depends on the features you want, the development hardware, and
      the target hardware.

      Using the most advanced profile (vs_2_*,vp30,etc) will most likely be
      the fastest and most powerful, but it will only run on the latest
      hardware.

      Using the older profiles (vs_1_*,vp20,etc) will run on older hardware,
      but may impose certain restrictions due to the limitations of hardware
      and might not be fully optimized for the latest hardware.

      The best way would be to have a code path for each type of shader and
      select which profile to use at run-time, by querying the graphics
      hardware to see which profiles it can support.

-------------------------------------------------
3. Semantics
-------------------------------------------------
3.1:  Why do we attach semantics to parameters and variables?

A:    Semantics are hints which tell the Cg compiler that the variables have
      access to read and/or write to the registers that contain the current
      vertex, color, texture coordinates, etc when the shader is called.
      Without semantics, shaders couldn't interact with the states and data
      that the underlying graphics sytem (OpenGL/DirectX) provide.

3.2:  When do we use semantics?

A:    Parameters with attached semantics are only considered by Cg when used
      with main(), otherwise they are ignored. Also, semantics can be
      attached to the return value of functions.
      
      For example:

      float4 main() : COLOR
      {
          return float4(1.0, 1.0, 0.0, 1.0);
      }

3.3:  What are all the semantics available to be used?

A:    The semantics available in all profiles are: POSITION, NORMAL,
      BINORMAL, BLENDINDICES, BLENDWEIGHT, TANGENT, PSIZE, TEXCOORD0-
      TEXCOORD7
      
      In addition, the following is a partial list of semantics
      available for some of the profiles:
      COLOR, COLOR0, DIFFUSE, COLOR1, SPECULAR, DEPTH, FOG
      
      For a complete and detailed listing, refer to Appendix B in [1].
      
3.4:  Anything to watch out for with semantics?

A:    Input binding semantics and output binding semantics can not be mixed
      within a single structure.

-------------------------------------------------
4. Shader Entry Point (main())
-------------------------------------------------
4.1:  Is there any special data structure, format, or variable name needed
      for passing parameters to shaders?

A:    Some paramenters must have semantics bound to them, but otherwise
      there are no special ways of using shaders.

4.2:  I don't see a function called main() in the shader code! How can it be
      called?

A:    By default, calling cgCreateProgramFromFile(...) assumes that the Cg
      file contains a function called main().
      
      However, the start of the shader program ("entry point") doesn't have
      to be called main(), as long as cgCreateProgramFromFile() is called
      with a parameter that tells what the name is of the "main()" function.
      
      In the following example, the main() function is called "MyMain()" and
      we tell Cg that when cgCreate...() is called.

      For example,
      MyShader.cg:
      void MyMain(...) {}

      MyCode.cpp:
      ...
      CGprogram Program = cgCreateProgramFromFile(context,
                                                  CG_SOURCE,
                                                  "MyShader.cg",
                                                  profile,
                                                  "MyMain",
                                                  NULL );
      ...

4.3:  In most of nVidia's examples, I see a struct being passed to the
      shader's main function. How does Cg handle the struct containing
      different parameters and what does it do when some parameters aren't
      given?

      For example,

      struct appdata
      {
          float4 position   : POSITION;
          float3 normal     : NORMAL;
          float3 color      : DIFFUSE;
          float3 TestColor  : SPECULAR;
      };

      struct vfconn
      {
          float4 pos : POSITION;
          float4 col0 : COLOR0;
      };

      void main(appdata IN, ...)
      {
        vfconn OUT;
        ...
        return OUT;
      }

A:    The members of the struct have semantics specified, which connect the
      variables in the shader code to the underlying graphics system
      (OpenGL/DirectX).

      For example, the POSITION semantic means that the value is read from
      the register that hold the homogenous position of the vertex being
      passed to the shader.

      The benefit is that any struct or parameters can be passed to
      functions. If a struct like

      struct mydata
      {
        float4 position : POSITION;
        float3 color    : DIFFUSE;
      };
      void main(mydata m) {...}

      is passed to a function, then the function will only be able to access
      and manipulate the data associate with the registers that contain the
      POSITION and DIFFUSE values from the underlying graphics system
      (OpenGL/DirectX).
      
      This also means that other registers, for example COLOR and
      TEXCOORD0, cannot be accessed or modified by that function.

4.4:  Why does nVidia use structs to pass and return their data to and from
      shaders?

A:    The motivation is the same as using structs in any programming language
      (like C/C++/Java). It is available to be used if desired, but it is not
      required.

4.5:  Does a struct containing parameters with semantics have to be passed to
      main()?

A:    No. They can be passed as parameters too.
      For example:
      void main( float4 color : COLOR ) {}

4.6:  In most of nVidia's examples, they use variables, such as "appdata IN",
      "vfconn OUT". Do the variable names have to be named IN and OUT?

A:    The variable names can be anything, as long as it is not a reserved
      keyword. Note that "in" and "out" are keywords. Variable names are
      case-sensitive.

4.7:  What's the relation of the previous question (4.6) to the keywords
      "in", "inout" and "out"? Why are they needed if data can be passed and
      returned like as in C?

A:    The keywords are available as a matter of convenience, so all
      parameters can be in the function prototype.

      The keyword "in" is a modifier for a parameter which tells Cg that the
      parameter takes input when the shader is called.

      Similarly, the modifier "out" tells Cg the parameter contains the
      output of the shader.

      Finally, "inout" can contain both the input and output.


      For example:
      
      void main( in  float4 inPos  : POSITION,
                 out float4 outColor: COLOR )

      {
        float4 newPos = inPos + /* ... */;
        outColor = /* ... */
      }

-------------------------------------------------
5. Vertex Shaders
-------------------------------------------------
5.1:  Are there any restrictions on the types of parameters vertex shaders
      can take?

A:    The short answer: No.
      The longer answer: The only limitation is that for a given shader,
      semantics assigned to variables can only be used once for input
      variables and once for output variables.

5.2:  Are there any restrictions on the return value of vertex shaders?

A:    Vertex shaders must return a four-component (xyzw) vertex with a
      POSITION binding semantic, which the rasterizer uses. It can be
      returned within a struct or by using the "out" keyword in the parameter
      list.

-------------------------------------------------
6. Fragment Shaders
-------------------------------------------------
6.1:  Are there any restrictions on the types of parameters fragment shaders
      can take?

A:    The short answer: No.
      The longer answer: The only limitation is that for a given shader,
      semantics assigned to variables can only be used once for input
      variables and once for output variables.

6.2:  Are there any restrictions on the return value of fragment shaders?

A:    Fragment shaders must return a color with four components (rgba) with a
      COLOR binding semantic and optionally depth components with a DEPTH
      binding semantic. It can be returned within a struct or by using the
      out keyword in the parameter list.

-------------------------------------------------
7. Interfacing C/C++ and OpenGL with Cg
-------------------------------------------------
7.1:  How are parameters in Cg accessed from C/C++?

A:    By using cgGetNamedParameter(). Refer to example following the next
      questions. Additional ways of accessing parameters can be found in [1].

7.2:  How are parameters in Cg set?

A:    By using cgGLSetParameter{1234}{fdv}(), which uses a naming convention
      similar to OpenGL. There are additional ways of setting data, which can
      be found in [1].

      For example, the following C code snippet creates a handle to the
      variable called "Diffuse" in the Cg program and sets its value to
      (1,0,0) (which is red).

      ...
      // assume valid Cg program source file and create a handle to it
      CGprogram Program = cgCreateProgramFromFile(...);
      
      // "glue" DiffuseParam to the parameter named "Diffuse" in the Cg code
      CGparameter DiffuseParam = cgGetNamedParameter(Program, "Diffuse");
      
      // Use "DiffuseParam" to update the value in the Cg shader code
      cgGLSetParameter3f(DiffuseParam, 1,0,0);
      ...


7.3:  When should Cg programs be called from C/C++/OpenGL?

A:    Cg programs should be called in the drawing loop where you want the
      shader to be applied and disabled at the end of the draw loop (similar
      to glBegin() and glEnd()).

      For example:

      void draw()
      {
        cgGLBindProgram( program );   // attach the shader
        cgGLEnableProfile( profile ); // specifies vertex or fragment shader

          // your drawing code goes here
          glBegin(GL_TRIANGLES);
            glColor3f(...);
            glVertex3fv(...);
          glEnd();


        cgGLDisableProfile(profile); // stops using shader
      }

-------------------------------------------------
8. Miscellaneous
-------------------------------------------------
8.1:  How can I write comments?

A:    The C/C++ commenting style is supported, which are single line
      comments (//) and multi-line comments (/*...*/).

      For example
      float4 pos; // This is a comment
      float4 dif; /* This is another comment */
      float4 col; /* This is a
                     multiline comment */

-------------------------------------------------
9. References
-------------------------------------------------
Most of this information in this FAQ can be found in greater detail in [1].

www.nVidia.com/cg
www.cgshaders.org

-------------------------------------------------
10. Bibliography
-------------------------------------------------
[1] CG Toolkit User's Manual (Cg_Toolkit.pdf) www.nVidia.com

-------------------------------------------------
11. Change Log
-------------------------------------------------
v0.003 Jun 06, 2003: Added link to Japanese version by Yukio Andoh
                     andoh AT opengl.com
v0 002 Jun 03, 2003: Completed question 7.3, minor fixes.
v0.001 May 30, 2003: Created.

                -------------------------------------------
               Contact us at http://www.FusionIndustries.com
                         (C)2003 Fusion Industries
              

Workshops

At SIGGRAPH this year, nVidia will be running on workshops on beginning and advanced shader techniques.

I've been to several nVidia sessions at the Game Developers Conference for the last several years and they've been very useful. Not only are the talks in-depth and enlightening, but you get to talk with people on the nVidia dev team.

My background is in graphics research, so being able to discuss the techniques I'm researching and working on with the dev team has helped me learn how to take advantage of the graphics hardware and learn from the demos they've created.
Must-Have Books

59

主题

984

帖子

1200

积分

金牌会员

Rank: 6Rank: 6

积分
1200
发表于 2009-11-24 22:24:00 | 显示全部楼层

Re: Re: 着色语言(Shader Language),以及HLSL VS GLSL VS CG

windRain_ly: Re: 着色语言(Shader Language),以及HLSL VS GLSL VS CG
1. The Cg/HLSL Language
-------------------------------------------------
1.1:  What's the difference between nVidia's Cg and Microsoft's HLSL
      (High Level Shading Language)?

A:    Cg and HLSL are actually the same language! Cg/HLSL was co-developed
      by nVidia and Microsoft. They have different names for branding
      purposes. HLSL is part of Microsoft's DirectX API and only compiles
      into DirectX code, while Cg can compile to DirectX and OpenGL.
      
      In this FAQ, Cg and HLSL can be used interchangably.


看看你自己引用的文章吧,足以证明我在12楼的所有观点
对于你在13楼的问题,我只能就说你对语言,runtime,profile等很多基本概念都不清楚.....

如果你不是作者的话,显然,我在2楼所说的“误导”已经发生了

5

主题

14

帖子

29

积分

注册会员

Rank: 2

积分
29
 楼主| 发表于 2009-11-25 09:21:00 | 显示全部楼层

Re: 着色语言(Shader Language),以及HLSL VS GLSL VS CG

拜托了clayman,我贴的文章我自己没看,恐怕你没有完全看完上面的回复吧。我从来没有否认cg和HLSL事同一种语言。到底是谁不清楚概念?我答复你的帖子都明确列出了概念定义的出处。

clayman兄,你还没有解释你说人家真够无知的理由?为什么避而不答?

文人相轻是常事,也不苛求,但你喜欢出言不逊,刚学了两天就“到处说这个茴香豆的茴字有好几种写法”,简直让人可发一笑。

我不是作者,但是你说的误导在我身上发生了吗?我错误认识了什么?你有没有看我在16楼写的帖子?

再拿JAVA举例,大家都说JAVA可移植性好,那是将JAVA虚拟机和JAVA同时说,这已经是一种通用的说法,好比吃饭没有必要说“吃菜、喝汤、拿筷子”。靠踢人满足自己的虚荣心,有意思吗?你真觉得有道理就给作者写信让他改。
还有,你认真看看这句话:
Cg and HLSL are actually the same language! Cg/HLSL was co-developed
      by nVidia and Microsoft. They have different names for branding
      purposes. HLSL is part of Microsoft's DirectX API and only compiles
      into DirectX code, while Cg can compile to DirectX and OpenGL.
作者开头同意了CG喝HLSL是同一种语言,然后又马上说: HLSL is part of Microsoft's DirectX API and only compiles  into DirectX code, while Cg can compile to DirectX and OpenGL.这就是又点出了cg和HLSL底层适用上的不同。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-6-16 00:56

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表