1

I have been told by experienced shader developers that while Cg is great for simple shaders, it is advised to do GLSL/HLSL directly for advanced shaders, due to bugs in resultant shader code.

What specifically are the limits and/or known problems with using Cg... are there certain things it just can't do, or is it a case of try and see... work with Cg until problems arise?

Mr. Boy
  • 60,845
  • 93
  • 320
  • 589
  • I think it is rather due to the fact that Cg doesn't support some of the newest features of OpenGL and Direct3D, supported by their respective "inhouse" shading languages, but I don't have any experience with Cg myself, so it's also just hear-say. – Christian Rau Nov 10 '11 at 18:41
  • I've never worked on newer than SM3 so I don't think this is (the only) factor. – Mr. Boy Nov 10 '11 at 19:54
  • It doesn't really matter if **you** ever worked with newer than SM3 shaders, but if the "experienced shader developers" (that told you not to use Cg) have, since you were not the one to come up with this claim, but the one who heard it and wants to know about its truth. – Christian Rau Nov 21 '11 at 16:39
  • @ChristianRau if I am targeting SM3, newer features are irrelevant to me. If you can't actually enumerate any of the problems/deficiencies then you're not really able to offer useful advice. I want ahrd facts, not here-say. – Mr. Boy Nov 23 '11 at 14:44
  • That's why I posted a comment and not an answer, which I myself am not sure it's correct. I didn't want to attack you in any way. I just wanted to make clear, that the fact that **you** want to use SM3 only is not a reason to believe that missing SM3+ features were not what the other developers had in mind when telling you not to use Cg, except if they were also only using SM3 and referring to SM3 only. But that was not deduceable from your comment. Somebody told me driving drunken is illegal, but since I don't drive drunken, I think he's wrong. – Christian Rau Nov 23 '11 at 14:54
  • I don't say my comment is correct or your comment is wrong. It's just the deduction process of your comment that was invalid. – Christian Rau Nov 23 '11 at 14:56

1 Answers1

0

Cg is fine within the scope of its age, as previously described. It hasn't had a major overhaul since the SM3 days. I would ask those "experienced shader developers" to cite specific errors.

I'm fond of HLSL within DirectX because the compiler seems a bit cleaner and preshaders are a fine thing.

GLSL is now required for contexts like iPad and WebGL anyway.

But Cg still has important uses. I use it in Maya almost daily, for example. Its close relationship to HLSL makes CgFX very useful for sharing between OpenGL/DirectX in our in-house tool chain.

bjorke
  • 3,295
  • 1
  • 16
  • 20