DX9 style Cg in, GLSL / GLSL ES out.
A modification of development from aras-p's HLSL2GLSL. I'm changing it to make it support Cg additional syntax, such as profile specific functions, and non-square matrices, etc.
- Translate non-square matrices to array of vectors, so that it can be used in GLSL 1.10 and GLSL ES 1.00
- Support Cg profile versions of functions.
- Only column major matrix mode is supported by this translator. Note that row major is default in Nvidia Cg compiler. You have to include #pragma pack_matrix(column_major) in your code to tell Cg compiler that you are using column-major matrices. If you don't use Cg compiler then just ignore it.
-
Only Direct3D 9 style HLSL is supported. No Direct3D 10/11 "template like" syntax, no geometry/tesselation/compute shaders, no abstract interfaces.
-
I bumped into some issues of HLSL2GLSL's preprocessor that I am not fixing. Most issues were with token pasting operator. So I preprocess source using mojoshader's preprocessor. Grab latest from mojoshader hg, it's awesome!
-
On Windows, the library is built with
_HAS_ITERATOR_DEBUGGING=0,_SECURE_SCL=0
defines, which affect MSVC's STL behavior. If this does not match defines in your application, totally strange things can start to happen! -
The library is not currently thread-safe.
-
No optimizations are performed on the generated GLSL, so it is expected that your platform will have a decent GLSL compiler. Or, use GLSL Optimizer, at Unity we use it to optimize shaders produced by HLSL2GLSL; gives a substantial performance boost on mobile platforms.