View Full Version : GLSL or CG ?

12-04-2004, 05:30 AM

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 ! :)

James Dolan
12-04-2004, 04:49 PM
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".

12-04-2004, 05:05 PM
And Cg for OpenGL only works at full power on NVidia cards (on ATI, with Cg, you are limited to arb_vp/fp1.0)

12-04-2004, 05:56 PM
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.

12-05-2004, 02:31 AM
Thanks for your advice. I'll go for CG then. :) 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 :)

12-05-2004, 03:57 AM
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.

12-05-2004, 07:11 AM
Here's the book on Cg: http://developer.nvidia.com/object/cg_tutorial_home.html

I found it very understandable and easy to read.

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


12-05-2004, 10:10 AM
Originally posted by weatx:
Here's the book on Cg: http://developer.nvidia.com/object/cg_tutorial_home.html
Great! It's even available in my native language. :)