I believe… and I could be wrong as I haven’t written any shaders in Unity… but I believe it’s GLSL you’ll need to be concerned with using. That’s why XNA shaders aren’t directly compatible with Unity because they are HLSL only (DirectX based shaders). But, I think there are some guides and websites out there dedicated to teaching you to convert between HLSL and GLSL, so you should pretty easily be able to translate from cgFX to GLSL.
Do you know if Unity will stop using CG as it is deprecated ? I couldn’t find any annoucement from Unity’s team.
It’s been 2 years since nvidia stopped developpment but it seem like unity still consider CG as the main shader programming language to use. The documentation is mainly about CG, moreover, the default peace of code that define a new shader created in the editor comes with CG code.
Cg’s always been pretty much a subset of HLSL anyway. I think Unity’s already kinda ‘broken past’ the limits of Cg with things like D3D11 geometry/tesselation shaders; you describe things with a CGPROGRAM block but use attributes which were never (afaik) a part of Cg.
Well, that didn’t answer the initial Question : “Do you know if Unity will stop using CG as it is deprecated ?”
Would it still be reasonable to start learning CG, ? Or asked in another way : Will CG be surpassed by other/better/more effecicient methods/languages of shader writing in the future? I don’t want to start learning deprecated technology, even though I understand that CG in Unity is a wonderful way of writing crossplatform shaders.
The current situation is pretty clear, there are 4 languages for writing shaders in unity:
Language SM1 SM2 SM3 OpenGL DirectX
Shaderlabs X X X
Cg X X X X
HLSL X X X
GLSL X X X
So it really depends on what your target platform is. If you want to deploy to windows, then chose Shaderlabs, Cg or HLSL. If you want to deploy to iphone or android, chose shaderlabs, cg or GLSL. If you want to deploy in all platforms, chose Shaderlabs or Cg.
Shaderlabs is the most compatible language, and typically gives best performance, but it is very limited.
Cg, is second as far as compatibility, but sometimes the translations (in particular to GLSL) are less than optimal.
Cg and HLSL are very similar, but there are differences. They are not the same language.
In my opinion, most games are better off using shaderlabs and Cg whenever possible, so you can deploy your game in all platforms, but sometimes for performance reasons you might want to write a GLSL shader yourself.
I have not heard anything about another multiplatform shader language for Unity, If Unity is thinking of adding a competitor to Cg, I would love to know.