GLSL or CG ?


I’d like to see your opinions on the choice of a shading language. I don’t know which one I should start learning. Actually, I would have no doubts if there hadn’t been one detail - in the nearest future I plan to start using DirectX. In this case it might be useful to know CG since it’s also compatible with the API. What do you advise?

Thanks in advance ! :slight_smile:

The languages them selves are all very similar (even GLSL vs HLSL). The big differences tend to be the little naming conventions in the languages. With that said, GLSL seems to be a little flaky on some drivers currently and the Cg compiler seems pretty solid, but then again, GLSL is “The standard”.

And Cg for OpenGL only works at full power on NVidia cards (on ATI, with Cg, you are limited to arb_vp/fp1.0)

Well, I suggest Cg, since you plan to move to D3D in the future. GLSL is heavily glstate based (good because less Uniforms that can clutter App code) and will be the hardest(‘hardest’ not ‘hard’) to port to HLSL, however porting Cg to HLSL is laughably easy. the CgD3D runtime is good, but since your going from OpenGL->D3D you might as well go that step further for ATI cards.

Thanks for your advice. I’ll go for CG then. :slight_smile: Anyway, after I learn CG it will much easier to switch to some other shading language (I hope so).

Are there any book or online-tutorials on CG you would recommend me?

Thanx once again :slight_smile:

I don’t kown a special book but ‘Texturing and Modelling’ is a really good common book about procedual texturing. Its more a compilation of important SIGGRAPH paper but IMHO you capture better idea behind this stuff.

Here’s the book on Cg:

I found it very understandable and easy to read.

You can try NeHe at to see if he’s made any tutorials yet, other than that just do a search for “Cg Tutorial” in google.


Originally posted by weatx:
Here’s the book on Cg:

Great! It’s even available in my native language. :slight_smile:


This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.