Is there a tool that can convert a fragment shader from hlsl to glsl or glsl to hlsl? I do not want to use cg since it is not able to work on mobile platforms.
Is there a tool that can make it so I only write a shader once?
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.Sign up to join this community
Shiny is a new library that aims to make material management and portable shader writing easy. This is achieved mostly with a preprocessor meta language, that can output any of CG, HLSL or GLSL. It is currently geared towards usage with Ogre graphics engine, but that part is abstracted into a separate component, so it shouldn't be hard to plug in any other engine. The library has been / is being integrated into OpenMV and Stunt Rally (disclaimer: I'm a member of the latter).
There is a lengthy introduction here.
I can't vouch for either one, but there is a utility available here for going from HLSL to GLSL: https://github.com/aras-p/hlsl2glslfork
and here for going the other direction: http://code.google.com/p/angleproject/
The first one is explained more here: http://aras-p.info/blog/2010/05/21/compiling-hlsl-into-glsl-in-2010/
There's the tool MojoShader which accomplishes what you want: http://icculus.org/mojoshader/