{"id":28166303,"url":"https://github.com/ravengine/shadertranspiler","last_synced_at":"2025-07-11T14:02:53.560Z","repository":{"id":40620369,"uuid":"294838753","full_name":"RavEngine/ShaderTranspiler","owner":"RavEngine","description":"A clean and simple cross-platform C++ library to convert GLSL shaders to HLSL, Metal, Vulkan, and WebGPU","archived":false,"fork":false,"pushed_at":"2025-04-01T01:02:46.000Z","size":14128,"stargazers_count":67,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-01T02:22:01.740Z","etag":null,"topics":["cpp17","glsl","metal","opengl","opengl-es","realtime-rendering","shaders","spirv","transpiler","vulkan","webgpu","wgsl"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RavEngine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-12T00:27:08.000Z","updated_at":"2025-04-01T01:02:51.000Z","dependencies_parsed_at":"2023-02-15T11:46:08.579Z","dependency_job_id":"2cf8129c-861c-4f8d-995f-e0e53700b07e","html_url":"https://github.com/RavEngine/ShaderTranspiler","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RavEngine%2FShaderTranspiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RavEngine%2FShaderTranspiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RavEngine%2FShaderTranspiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RavEngine%2FShaderTranspiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RavEngine","download_url":"https://codeload.github.com/RavEngine/ShaderTranspiler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254346620,"owners_count":22055809,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp17","glsl","metal","opengl","opengl-es","realtime-rendering","shaders","spirv","transpiler","vulkan","webgpu","wgsl"],"created_at":"2025-05-15T13:11:54.119Z","updated_at":"2025-05-15T13:12:21.586Z","avatar_url":"https://github.com/RavEngine.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ShaderTranspiler\nA clean and simple C++ library to convert GLSL shaders to HLSL, Metal, Vulkan, and WebGPU. It leverages [glslang](https://github.com/KhronosGroup/glslang), \n[SPIRV-Cross](https://github.com/KhronosGroup/SPIRV-Cross), [SPIRV-Tools](https://github.com/KhronosGroup/SPIRV-Tools), [Tint](https://dawn.googlesource.com/tint), and [dxcompiler](https://github.com/microsoft/DirectXShaderCompiler) to handle cross-compilation of shaders. \n\n## Supported APIs:\n- GLSL -\u003e ESSL (OpenGL ES) \n- GLSL -\u003e HLSL (DirectX)\n- GLSL -\u003e DXIL\\* (DirectX)\n- GLSL -\u003e MSL (Metal, mobile and desktop)\n- GLSL -\u003e MSL Binary (macOS host only, requires Xcode to be installed)\n- GLSL -\u003e SPIR-V (Vulkan)\n- GLSL -\u003e WGSL (WebGPU)\n\n\n## How to use\n```cpp\n// include the library\n#include \u003cShaderTranspiler/ShaderTranspiler.hpp\u003e\n#include \u003ciostream\u003e\n\nusing namespace std::filesystem;\nusing namespace std;\n\n//the library's namespace\nusing namespace shadert;\n\nint main(){\n\n  // create an instance\n  ShaderTranspiler s;\n\n  // Create a CompileTask with the path to your shader and its stage.\n  // The path is required because this library supports the OpenGL #include extension\n  // For use cases involving code generation, MemoryCompileTask is also provided.\n  FileCompileTask task(path(\"Scene.vert\"),ShaderStage::Vertex);\n\n  // configure the compile with an Options object\n  Options opt;\n  opt.mobile = false; //used for OpenGL ES or Metal iOS\n  opt.version = 15;   //stores the major and minor version, for Vulkan 1.5 use 15\n\n  try{\n    // call CompileTo and pass the CompileTask and the Options\n    CompileResult result = s.CompileTo(task, TargetAPI::Vulkan, opt);\n\n    // not all of these will be populated depending on the target\n    cout \u003c\u003c result.sourceData \u003c\u003c endl;\n    cout \u003c\u003c result.binaryData \u003c\u003c endl;\n  }\n  catch(exception\u0026 e){\n    // library will throw on errors\n    cerr \u003c\u003c e.what() \u003c\u003c endl;\n    return 1;\n  }\n\n  return 0;\n}\n```\n\n## How to compile\nThis library uses CMake. Simply call `add_subdirectory` in your CMakeLists.txt.\n```cmake\n# ...\nadd_subdirectory(\"ShaderTranspiler\")\n# ...\ntarget_link_libraries(\"your-program\" PRIVATE \"ShaderTranspiler\")\n```\nYou will need a C++20 compiler to build the library (but not to use it, the header is compatible with C++17).\n\nIf you only want to play around with the library, you can use one of the init scripts (`init-mac.sh`, `init-win.sh`) and modify `main.cpp` in the test folder.\n\n\\* DXIL support is restricted to Windows hosts by default. To generate DXIL on non-Windows hosts, clone with submodules to get the [DirectXShaderCompiler](https://github.com/microsoft/DirectXShaderCompiler)\nsource code, and set `ST_BUNDLED_DXC` to `1` in your CMake configuration. This will compile DXC from source and use that instead of the compiler that comes with Direct3D for Windows. Because of how big DXC is \nand how long it takes to compile, this feature is disabled by default. \n\n# Issue reporting\nKnown issues:\n- Writing SPIR-V binaries on a Big Endian machine will not work.\n\nUse the Issues section to report problems. Contributions are welcome, use pull requests. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fravengine%2Fshadertranspiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fravengine%2Fshadertranspiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fravengine%2Fshadertranspiler/lists"}