Standalone Converter

Download HLSL2GLSLConverter.

Standalone HLSL2GLSLConverter allows off-line conversion of shaders authored in HLSL to GLSL. Command line options for the tool are given in the table below:

Argument  Description
-h Print help message
-i <filename> Input file path (relative to the search directories)
-d <dirname> Search directory to look for input file as well as all #include files. Every search directory should be specified using -d argument
-o <filename> Output file to write converted GLSL source to
-e <funcname> Shader entry point
-c Compile converted GLSL shader
-t <type> Shader type. Allowed values:
 vs – vertex shader
 ps – pixel shader
 gs – geometry shader
 ds – domain shader
 hs – domain shader
 cs – domain shader
-noglsldef Do not include glsl definitions into the converted source

Command line example:

HLSL2GLSLConverter -i ConverterTest.fx -d .\testshaders -d .\ -t vs -e TestVS -c -o .\testshaders\ConvertedShader.txt

By default, the converter includes auxiliary GLSL definitions into the converter source. This can be disabled with -noglsldef command line option, but the definitions file GLSLDefinitions.h is required for the shader file to be compiled and must be included manually.

 

When compiling GLSL shader, Diligent Engine adds the following lines on top of the converted GLSL source.

For desktop GL:

For GLES:

Also on Android, the engine defines the following extension when compiling geometry shader:

and the following extension when compiling tessellation control (hull) or tessellation evaluation (domain) shader:

Besides that, the engine also defines one of the following macros depending on the type of the shader being compiled: VERTEX_SHADER, FRAGMENT_SHADER, GEOMETRY_SHADER, TESS_CONTROL_SHADER, TESS_EVALUATION_SHADER, COMPUTE_SHADER. If converted source is not handled by the Diligent Engine, one of the macros above must always be defined before including GLSLDefinitions.h.

Download HLSL2GLSLConverter.