| 1 | # MojoShader |
| 2 | |
| 3 | https://icculus.org/mojoshader/ |
| 4 | |
| 5 | MojoShader is a zlib-licensed library to work with Direct3D shaders on |
| 6 | alternate 3D APIs and non-Windows platforms. The primary motivation is |
| 7 | moving shaders to OpenGL languages on the fly. The developer deals with |
| 8 | "profiles" that represent various target languages, such as GLSL or |
| 9 | ARB_*_program. |
| 10 | |
| 11 | This allows a developer to manage one set of shaders, presumably written |
| 12 | in Direct3D HLSL, and use them across multiple rendering backends. This |
| 13 | also means that the developer only has to worry about one (offline) |
| 14 | compiler to manage program complexity, while MojoShader itself deals with |
| 15 | the reduced complexity of the bytecode at runtime. |
| 16 | |
| 17 | MojoShader provides both a simple API to convert bytecode to various |
| 18 | profiles, and (optionally) basic glue to rendering APIs to abstract the |
| 19 | management of the shaders at runtime. |
| 20 | |
| 21 | Work is in progress to allow MojoShader to work as a replacement stack for |
| 22 | the D3DX shader tools. The library already provides a preprocessor and an |
| 23 | assembler to generate bytecode from low-level source, and construction of |
| 24 | a full HLSL compiler is in progress. |
| 25 | |
| 26 | The library is meant to be statically linked to an application (just add a |
| 27 | few .c files and headers to your build), allows the app to optionally |
| 28 | specify an allocator, and is thread safe (although OpenGL itself is not). |
| 29 | It is meant to be embedded in games with a minimum of fuss. |
| 30 | |
| 31 | To use this in your project: |
| 32 | |
| 33 | - Add mojoshader*.c and mojoshader*.h to your project. |
| 34 | - Compile mojoshader*.c |
| 35 | - If you don't have a C99-compliant compiler, like Microsoft Visual Studio, |
| 36 | you'll need to compile the .c files as C++ to get them to build. |
| 37 | - If you don't have cmake to generate mojoshader_version.h, you can either |
| 38 | add a blank file with that name, or add MOJOSHADER_NO_VERSION_INCLUDE to |
| 39 | your preprocessor definitions. |