Shader Translator

Link: http://confettishadertranslator.azurewebsites.net/

 

This project, Confetti Shader Translator, was started from a question that “Is there a way to create shaders from one shader language for various platform. The most common way to this would be using Microsoft’s DirectX Compiler to translate HLSL shader to SPIR-V.

But I also wanted to resolve a few issues below:

  • The translated shaders should have same pre-processors from the original shader
  • It can be expanded for using custom shader language in the future

To handle this,  I determined to expand a reference project HLSLParser because, first, I don’t need to make everything from scratch, second, it seems to be able to be expanded for custom shader language because it makes a tree structure, which is more maintainable to modify it, from the original shader language (HLSL).

But HLSLParser had a lot of limitations. It didn’t support the latest version of HLSL, GLSL, and MSL. And, there were a lot of missing syntax such as if-else statement, loop statement, and etc. Overall, the most difficult part was to support pre-processors.

So, I modified the parser to support the features already mentioned before and added the corresponding features for each shader languages (HLSL, GLSL, and MSL).

And, for accessibility, I made our shader translator as a web-site because the user can use this tool without concern of using any specific platform.

Now, it supports HLSL, GLSL, and MSL. In near future, it will also support PS4 and Nintendo switch’s shader languages.

 

References