All Projects → alaingalvan → Crossshader

alaingalvan / Crossshader

Licence: mit
⚔️ A tool for cross compiling shaders. Convert between GLSL, HLSL, Metal Shader Language, or older versions of GLSL.

Projects that are alternatives of or similar to Crossshader

Shaderconductor
ShaderConductor is a tool designed for cross-compiling HLSL to other shading languages
Stars: ✭ 1,146 (+914.16%)
Mutual labels:  compiler, opengl, glsl, vulkan, hlsl, metal
Pmtech
Lightweight, multi-platform, data-oriented game engine.
Stars: ✭ 478 (+323.01%)
Mutual labels:  opengl, webgl, glsl, vulkan, hlsl, metal
Reshade
A generic post-processing injector for games and video software.
Stars: ✭ 2,285 (+1922.12%)
Mutual labels:  compiler, opengl, glsl, vulkan, hlsl
Bgfx
Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.
Stars: ✭ 10,252 (+8972.57%)
Mutual labels:  opengl, webgl, vulkan, metal, directx
3d Game Shaders For Beginners
🎮 A step-by-step guide to implementing SSAO, depth of field, lighting, normal mapping, and more for your 3D game.
Stars: ✭ 11,698 (+10252.21%)
Mutual labels:  opengl, webgl, glsl, vulkan, hlsl
Bulllord Engine
lightspeed lightweight elegant game engine in pure c
Stars: ✭ 539 (+376.99%)
Mutual labels:  opengl, webgl, vulkan, metal
Pmfx Shader
Cross platform shader system for HLSL, GLSL, Metal and SPIR-V.
Stars: ✭ 245 (+116.81%)
Mutual labels:  webgl, glsl, hlsl, metal
Filament
Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2
Stars: ✭ 13,215 (+11594.69%)
Mutual labels:  opengl, webgl, vulkan, metal
Shaderc Rs
Rust bindings for the shaderc library.
Stars: ✭ 143 (+26.55%)
Mutual labels:  compiler, glsl, vulkan, hlsl
Ouzel
C++ game engine for Windows, macOS, Linux, iOS, tvOS, Android, and web browsers
Stars: ✭ 607 (+437.17%)
Mutual labels:  opengl, glsl, hlsl, metal
Llgl
Low Level Graphics Library (LLGL) is a thin abstraction layer for the modern graphics APIs OpenGL, Direct3D, Vulkan, and Metal
Stars: ✭ 1,011 (+794.69%)
Mutual labels:  opengl, vulkan, metal, directx
Bonzomatic
Live shader coding tool and Shader Showdown workhorse
Stars: ✭ 829 (+633.63%)
Mutual labels:  opengl, glsl, hlsl, directx
Shaderc
A collection of tools, libraries, and tests for Vulkan shader compilation.
Stars: ✭ 1,016 (+799.12%)
Mutual labels:  compiler, glsl, vulkan, hlsl
Shadergen
Proof-of-concept library for generating HLSL, GLSL, and Metal shader code from C#,
Stars: ✭ 395 (+249.56%)
Mutual labels:  opengl, glsl, vulkan, hlsl
Fiber2d
Cross-platform 2D Game Engine in pure Swift
Stars: ✭ 415 (+267.26%)
Mutual labels:  opengl, vulkan, metal, directx
Awesome Glsl
🎇 Compilation of the best resources to learn programming OpenGL Shaders
Stars: ✭ 530 (+369.03%)
Mutual labels:  opengl, webgl, glsl
Renderdoc
RenderDoc is a stand-alone graphics debugging tool.
Stars: ✭ 5,969 (+5182.3%)
Mutual labels:  opengl, vulkan, directx
Gfx
[maintenance mode] A low-overhead Vulkan-like GPU API for Rust.
Stars: ✭ 5,045 (+4364.6%)
Mutual labels:  opengl, vulkan, metal
Glchaos.p
3D GPUs Strange Attractors and Hypercomplex Fractals explorer - up to 256 Million particles in RealTime
Stars: ✭ 590 (+422.12%)
Mutual labels:  opengl, webgl, glsl
Fna3d
FNA3D - 3D Graphics Library for FNA
Stars: ✭ 111 (-1.77%)
Mutual labels:  opengl, vulkan, metal

Logo

⚔️ CrossShader

Npm Package cmake-img License Travis Tests devDependency Status

A 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 glslang and SPIRV-Cross, exposing a simpler interface to transpile shaders.

Installation

Node.js Installation

npm i cross-shader -S

Note the use of dash-case vs CamelCase for the npm module name, this is to follow the JavaScript community's focus on making names that fit well with browser URLs.

Using this module will require Node 8.x or above, or a browser that supports WebAssembly.

C++ Installation

First add the repo as a submodule in your dependencies folder such as external/:

cd external
git submodule add https://github.com/alaingalvan/crossshader.git

Then in your CMakeLists.txt file, include the following:

# ⬇ Add your dependency:
add_subdirectories(external/crossshader)

# 🔗 Link CrossShader to your project:
target_link_libraries(
    ${PROJECT_NAME}
    CrossShader
)

Usage

This 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.

Node.js Example

TypeScript types are included, refer to cross-shader.d.ts for more details.

Similar to other WebAssembly modules, importing the module gives you a promise to the compiled WebAssembly binary:

import xsdr from 'cross-shader';

xsdr.then(({ compile, ShaderFormat, ShaderStage }) => {
  const ioptions = {
    format: ShaderFormat.GLSL,
    stage: ShaderStage.Vertex,
    es: false,
    glslVersion: 450
  };

  const ooptions = {
    format: ShaderFormat.GLSL,
    es: true,
    glslVersion: 100
  }

  let outputString = compile(inputString, ioptions, ooptions);
});

C++ Example

Refer to src/CrossShader/CrossShader.h for more details.

#include "CrossShader/CrossShader.h"

void main()
{
  xsdr::InputOptions ioptions;
  ioptions.format = xsdr::ShaderFormat::GLSL;
  ioptions.stage = xsdr::ShaderStage::Vertex;
  ioptions.es = false;
  ioptions.glslVersion = 110;

  xsdr::OutputOptions ooptions;
  ooptions.format = xsdr::ShaderFormat::GLSL;
  ooptions.es = true;
  ooptions.glslVersion = 100;

  std::string out = xsdr::compile(vertSource, ioptions, ooptions);
}

Development

Be sure to have:

And type the following in any folder:

# 🐑 Clone the repo
git clone https://github.com/alaingalvan/crossshader.git --recurse-submodules

# 💿 go inside the folder
cd crossshader

# 👯 If you forget to `recurse-submodules` you can always run:
git submodule update --init

From there we'll need to set up our build files. Be sure to have the following installed:

Then type the following in your terminal from the repo folder:

# 👷 Make a build folder
mkdir build
cd build

# 🖼️ To build your Visual Studio solution on Windows x64
cmake .. -A x64

# 🍎 To build your XCode project on Mac OS
cmake .. -G Xcode

# 🐧 To build your MakeFile on Linux
cmake ..

# 🔨 Build on any platform:
cmake --build .

Whenever 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.

WebAssembly

Note: if you're on Windows, I would highly recommend using the Windows Subsystem for Linux.

First, install the latest version of Emscripten via the Emscripten SDK. Make sure to add it's Emscripten installation to your PATH, then:

# ⚠️ Possible dependencies you might need:
sudo apt-get update
sudo apt-get install cmake build-essential llvm

# 🏃 Then run the following:
mkdir wasm
cd wasm
emcmake cmake ..
emmake make CrossShader -j

License

CrossShader is licensed as either MIT or Apache-2.0, whichever you would prefer.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].