Convert Cg shaders with hlsl2glslfork ?

I’m running Panda3D on a computer that doesn’t have Cg support, it also looks like Cg is deprecated by Nvidia.

Is it possible to use hlsl2glslfork to convert these, is there a chance hlsl2glslfork could be integrated with Panda3D to run Cg shaders in the future ?


CG is very very similar syntax to hlsl, so in theory it should work. As cg can compile to glsl there isn’t plans on adding hlsl2glsl when I asked about it a couple years ago.

To help me learn glsl (and shaders in general) a little better I made skeleton glsl shaders. Then i would rewrite the cg shaders by hand.

Oh, and I just logged into the forum to post the Cg to GLSL converter that I hacked up yesterday. I’ll post it later today.

FWIW there is no such thing as “a computer that does not support Cg”. Every computer that supports shaders supports Cg. You mean that your build Panda3D was compiled without the Cg Runtime enabled?

The NVIDIA Cg Runtime is capable of transpiling Cg to HLSL and GLSL (which is in practice often what happens in Panda3D - except for more basic shaders, which are translated to ARB assembly language instead, which is more widely supported and compiles faster). The conversion script I wrote basically invokes the Cg runtime to transpile to GLSL and remaps the inputs so that it they can be recognized by Panda’s GLSL module.

Here it is, by the way: