Cg and Sh

I’ve been learning Cg for awhile now and I’ve just heard about Sh. After browsing the Sh page for awhile I got a little more curious about it.

I was wondering if there is any performance differences between Cg and Sh. Are there Cg vs Sh documents to read?

What is Sh? Is it OpenGL Shading Language? I’ll tell you on nVidia cards, GLSL and Cg is compiled by the same compiler, no speed differences. On ATI cards, I haven’t tested, but it seems ATI may optimize the GLSL compiler and perform better than Cg IN THE FUTURE, but the ATI GLSL compiler has a lot of bugs currently.

What is Sh? Is it OpenGL Shading Language?

No Sh is not GLSL. You can check it out here:

As far as speed…I really don’t know but I’m sure there’s not any significant difference.


Then I’ll stick with Cg. The Sh method of embedding compiled code right inside your C++ program sounds cool, but at the same speed I would rather load a script that I can edit with recompling my whold program.

Yeah I agree, being able to modify a shader while the program is running and see instant results is quite cool. And since there is no way Sh could be faster, Cg is the way to go if run-time shader modifying is what you are after. I’m not trying to say Sh is bad, it’s quite good and capable but I’m also going to stick with Cg & GLSL. :slight_smile:


So is Cg supported on ATI already? I thought they were going to support only GLSL… but to be honest, I’ve been disconencted from the shader world (other than old fragment programs) since Cg and stuff started popping out…

… and I’ve had no ATI cards in the meanwhile :wink:

I’m not entirely sure I see the advantage to being able to modify shader scripts at runtime…I used to think it would be useful, but in practice the modification of the script usually goes hand in hand with a modification in the code using the script, so it seems a bit pointless.
If you need the ability to modify at runtime, just wrap your shaders in a DLL.

Well, I suppose it shaves about a minute of compile time from your development/testcycle.

Which is always nice if you just want to fix that one compiler error you receive when you run your program and try to use that shader.