By request, I hacked up a little script that uses cgc (part of the NVIDIA Cg Toolkit) to transpile a Cg shader to GLSL.
It remaps inputs from Cg-style to GLSL-style. Not all inputs are converted correctly (eg. fog and material inputs aren’t converted at present), but most shaders I tried work fine. If you find one that doesn’t, let me know.
Source code of cg2glsl:
There’s some oddity with the way cgc converts matrices to GLSL. Instead of creating mat4 inputs, it does this:
Simply changing it to a mat4 isn’t enough, since the ordering is different. So I just checked in a fix to Panda’s GLSL back-end so that it can support passing matrices as an array of vectors this way (only for Cg-style inputs, not for p3d_ inputs). This means that in order to use the transpiled shaders, you need a very recent build of Panda.
Buildbot builds containing the necessary changes are available here:
panda3d.org/download.php?pl … =devel&sdk