{"id":13534463,"url":"https://github.com/alaingalvan/CrossShader","last_synced_at":"2025-04-01T22:31:37.750Z","repository":{"id":33792622,"uuid":"158095606","full_name":"alaingalvan/CrossShader","owner":"alaingalvan","description":"⚔️ A tool for cross compiling shaders. Convert between GLSL, HLSL, Metal Shader Language, or older versions of GLSL.","archived":false,"fork":false,"pushed_at":"2023-03-04T03:03:13.000Z","size":1482,"stargazers_count":273,"open_issues_count":16,"forks_count":10,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-08-02T07:26:04.153Z","etag":null,"topics":["apple-metal","compiler","directx","glsl","hlsl","metal","opengl","transpiler","vulkan","webgl"],"latest_commit_sha":null,"homepage":"https://alain.xyz/libraries/crossshader","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/alaingalvan.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-11-18T15:02:06.000Z","updated_at":"2024-07-29T06:52:55.000Z","dependencies_parsed_at":"2024-01-03T04:07:13.909Z","dependency_job_id":"1e1a67e1-4960-4746-9bcd-a31fcde428b6","html_url":"https://github.com/alaingalvan/CrossShader","commit_stats":{"total_commits":46,"total_committers":1,"mean_commits":46.0,"dds":0.0,"last_synced_commit":"3d4611f0fe5f24b42a1a8d8a43e032b106ffb955"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alaingalvan%2FCrossShader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alaingalvan%2FCrossShader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alaingalvan%2FCrossShader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alaingalvan%2FCrossShader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alaingalvan","download_url":"https://codeload.github.com/alaingalvan/CrossShader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222779888,"owners_count":17036542,"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":["apple-metal","compiler","directx","glsl","hlsl","metal","opengl","transpiler","vulkan","webgl"],"created_at":"2024-08-01T07:01:33.626Z","updated_at":"2024-11-02T21:31:23.646Z","avatar_url":"https://github.com/alaingalvan.png","language":"C++","readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://alain.xyz/libraries/crossshader\"\u003e\n    \u003cimg alt=\"Logo\" src=\"docs/cover.png\"/\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003ch1 align=\"center\"\u003e\n  ⚔️ CrossShader\n\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n\n[![Npm Package][npm-img]][npm-url]\n[![cmake-img]][cmake-url]\n[![License][license-img]][license-url]\n[![Travis Tests][travis-img]][travis-url]\n[![Dependency Status][deps-img]][deps-url]\n\n\u003c/p\u003e\n\nA cross compiler for shader languages. Convert between **SPIR-V**, **GLSL / GLSL ES**, **HLSL**, **Metal Shader Language**, or older versions of a given language. Cross Shader wraps [DirectX Shader Compiler](https://github.com/microsoft/DirectXShaderCompiler), [glslang](https://github.com/KhronosGroup/glslang), [Mozilla Naga](https://github.com/gfx-rs/naga) and [SPIRV-Cross](https://github.com/KhronosGroup/SPIRV-Cross/), exposing a simpler interface to transpile shaders.\n\n## Installation\n\n### Node.js Installation\n\n```bash\nnpm i cross-shader -S\n```\n\nUsing this module will require Node 8.x or above, or [a browser that supports WebAssembly](https://caniuse.com/#feat=wasm).\n\n### C++ Installation\n\nFirst add the repo as a submodule in your dependencies folder such as `external/`:\n\n```bash\ncd external\ngit submodule add https://github.com/alaingalvan/crossshader.git\n```\n\nThen in your `CMakeLists.txt` file, include the following:\n\n```cmake\n# ⬇ Add your dependency:\nadd_subdirectories(external/crossshader)\n\n# 🔗 Link CrossShader to your project:\ntarget_link_libraries(\n    ${PROJECT_NAME}\n    CrossShader\n)\n```\n\n## Usage\n\nThis library exposes a single function `compile(...)` and its config structs/enums, and returns either the output string, or throws an exception if there's an error compiling, with the error message exposed in the exception object.\n\n### Node.js Example\n\nTypeScript types are included, refer to [`cross-shader.d.ts`](/cross-shader.d.ts) for more details.\n\nSimilar to other WebAssembly modules, importing the module gives you a promise to the compiled WebAssembly binary:\n\n```js\nimport xsdr from \"cross-shader\";\n\nxsdr.then(({ compile, ShaderFormat, ShaderStage }) =\u003e {\n  const ioptions = {\n    format: ShaderFormat.GLSL,\n    stage: ShaderStage.Vertex,\n    es: false,\n    glslVersion: 450,\n  };\n\n  const ooptions = {\n    format: ShaderFormat.GLSL,\n    es: true,\n    glslVersion: 100,\n  };\n\n  let outputString = compile(inputString, ioptions, ooptions);\n});\n```\n\n### C++ Example\n\nRefer to [`src/CrossShader/CrossShader.h`](/src/CrossShader.h) for more details.\n\n```cpp\n#include \"CrossShader/CrossShader.h\"\n\nvoid main()\n{\n  xsdr::InputOptions ioptions;\n  ioptions.format = xsdr::ShaderFormat::GLSL;\n  ioptions.stage = xsdr::ShaderStage::Vertex;\n  ioptions.es = false;\n  ioptions.glslVersion = 110;\n\n  xsdr::OutputOptions ooptions;\n  ooptions.format = xsdr::ShaderFormat::GLSL;\n  ooptions.es = true;\n  ooptions.glslVersion = 100;\n\n  std::string out = xsdr::compile(vertSource, ioptions, ooptions);\n}\n```\n\n## Development\n\nBe sure to have:\n\n- [Git](https://git-scm.com/downloads)\n\n- Any terminal such as [Hyper](https://hyper.is/)\n\nAnd type the following in any folder:\n\n```bash\n# 🐑 Clone the repo\ngit clone https://github.com/alaingalvan/crossshader.git --recurse-submodules\n\n# 💿 go inside the folder\ncd crossshader\n\n# 👯 If you forget to `recurse-submodules` you can always run:\ngit submodule update --init\n\n```\n\nFrom there we'll need to set up our build files. Be sure to have the following installed:\n\n- [CMake](https://cmake.org/)\n\n- An IDE such as [Visual Studio](https://visualstudio.microsoft.com/downloads/), [XCode](https://developer.apple.com/xcode/), or a compiler such as [GCC](https://gcc.gnu.org/).\n\nThen type the following in your terminal from the repo folder:\n\n```bash\n# 🖼️ To build your Visual Studio solution on Windows x64\ncmake . -B build/vs -A x64\n\n# 🍎 To build your XCode project on Mac OS\ncmake .. -B build/xcode -G Xcode\n\n# 🐧 To build your MakeFile on Linux\ncmake -B build/make ..\n\n# 🔨 Build on any platform:\ncmake --build .\n```\n\nWhenever you add new files to the project, run `cmake ..` from your solution/project folder, and if you edit the `CMakeLists.txt` file be sure to delete the generated files and run Cmake again.\n\n### WebAssembly\n\n**Note**: if you're on Windows, I would highly recommend using the [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10#install-the-windows-subsystem-for-linux).\n\nFirst, install the latest version of Emscripten via the [Emscripten SDK](https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html). Make sure to add it's Emscripten installation to your `PATH`, then:\n\n```bash\n# ⚠️ Possible dependencies you might need:\nsudo apt-get update\nsudo apt-get install cmake build-essential llvm\n\n# 🏃 Then run the following:\nemcmake cmake . -B build/wasm\nemmake make CrossShader -j\n```\n\n## License\n\nCrossShader is licensed as either **MIT** or **Apache-2.0**, whichever you would prefer.\n\n[cmake-img]: https://img.shields.io/badge/cmake-3.6-1f9948.svg?style=flat-square\n[cmake-url]: https://cmake.org/\n[license-img]: https://img.shields.io/:license-mit-blue.svg?style=flat-square\n[license-url]: https://opensource.org/licenses/MIT\n[travis-img]: https://img.shields.io/travis/com/alaingalvan/crossshader.svg?style=flat-square\n[travis-url]: https://www.travis-ci.com/github/alaingalvan/crossshader\n[npm-img]: https://img.shields.io/npm/v/cross-shader.svg?style=flat-square\n[npm-url]: http://npm.im/cross-shader\n[npm-download-img]: https://img.shields.io/npm/dm/cross-shader.svg?style=flat-square\n[deps-url]: https://libraries.io/npm/cross-shader\n[deps-img]: https://img.shields.io/librariesio/release/npm/cross-shader?style=flat-square\n[codecov-img]: https://img.shields.io/codecov/c/github/alaingalvan/crossshader.svg?style=flat-square\n[codecov-url]: https://codecov.io/gh/alaingalvan/crossshader\n","funding_links":[],"categories":["Graphics","Specialty Topics"],"sub_categories":["Shaders"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falaingalvan%2FCrossShader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falaingalvan%2FCrossShader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falaingalvan%2FCrossShader/lists"}