开发者

Are there major differences between shader languages?

I am currently learning GLSL. It would seem that once you learn one of the shader languages, learning one of the others would not be too difficult. Is it something analogous to learning a widget toolset like wxWidgets and then s开发者_JAVA百科witching to Qt? Once you get the idea of what is happening within one widget toolset, another toolset will do something similar since they are ultimately doing almost the same thing at some point? What are your experiences with going from one shader language to another?


Cg and HLSL are almost the same (same builtin function names). GLSL looks and feels a bit different (i.e. mix instead of lerp, use of a main-like function), but the overall transition is still easy. The only differences are in the details and in the respective APIs (i.e. stuff like matrix storage order).

Switching between shading languages is way easier than switching between GUI toolkits…


HLSL has some differences from GLSL. Nothing too different from what I've read. There are some translation tools out there. There is a SourceForge project HLSL To GLSL tool. Also, I believe that the NVidia Cg toolkit can generate HLSL or GLSL.


In my slightly limited experience, I'd agree with everyone here that they are very, very similar and it's not a problem to switch between them. However, do beware that, as seems to be the case with most OpenGL/DirectX clashes, I find HLSl to have a few more nice convenience functions that make it a little more fun to use. I'm talking small things, like saturate, here. However, beyond minor structural differences, like passing around inputs, the basic concepts are one hundred percent the same.

Enjoy! Shaders are a lot of fun.


You are right - GLSL/HLSL/Cg shading languages are subset of C programming language, so they are very similar.


the origin of directx 3d lies in opengl. microsoft reprogrammed the opengl api to a certain point, because of this the languages should be similiar.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜