cg2glsl

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:
gist.github.com/rdb/e30651fa8f110a766076

There’s some oddity with the way cgc converts matrices to GLSL. Instead of creating mat4 inputs, it does this:

vec4 _mat_modelproj1[4];

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