All Projects → PENGUINLIONG → inline-spirv-rs

PENGUINLIONG / inline-spirv-rs

Licence: other
Compile GLSL/HLSL/WGSL and inline SPIR-V right inside your crate.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to inline-spirv-rs

ShaderWriter
Library used to write shaders from C++, and export them in either GLSL, HLSL or SPIR-V.
Stars: ✭ 171 (+714.29%)
Mutual labels:  glsl, hlsl, spirv
Cs2x
Transpiles a C# subset to non .NET languages and runtimes. (Powered by Roslyn)
Stars: ✭ 97 (+361.9%)
Mutual labels:  glsl, hlsl
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 (+55604.76%)
Mutual labels:  glsl, hlsl
Shaderc Rs
Rust bindings for the shaderc library.
Stars: ✭ 143 (+580.95%)
Mutual labels:  glsl, hlsl
Bonzomatic
Live shader coding tool and Shader Showdown workhorse
Stars: ✭ 829 (+3847.62%)
Mutual labels:  glsl, hlsl
Shaderc
A collection of tools, libraries, and tests for Vulkan shader compilation.
Stars: ✭ 1,016 (+4738.1%)
Mutual labels:  glsl, hlsl
Krafix
GLSL cross-compiler based on glslang and SPIRV-Cross
Stars: ✭ 124 (+490.48%)
Mutual labels:  glsl, hlsl
Gpu Gems Book Source Code
💿 CD Content ( Source Code ) Collection of Book <GPU Gems > 1~ 3 | 《GPU精粹》 1~ 3 随书CD(源代码)珍藏
Stars: ✭ 567 (+2600%)
Mutual labels:  glsl, hlsl
Reshade
A generic post-processing injector for games and video software.
Stars: ✭ 2,285 (+10780.95%)
Mutual labels:  glsl, hlsl
Spirv Vm
Virtual machine for executing SPIR-V
Stars: ✭ 173 (+723.81%)
Mutual labels:  glsl, hlsl
Shadered
Lightweight, cross-platform & full-featured shader IDE
Stars: ✭ 3,247 (+15361.9%)
Mutual labels:  glsl, hlsl
Imguicolortextedit
Colorizing text editor for ImGui
Stars: ✭ 772 (+3576.19%)
Mutual labels:  glsl, hlsl
Slang
Making it easier to work with shaders
Stars: ✭ 627 (+2885.71%)
Mutual labels:  glsl, hlsl
Shaderconductor
ShaderConductor is a tool designed for cross-compiling HLSL to other shading languages
Stars: ✭ 1,146 (+5357.14%)
Mutual labels:  glsl, hlsl
Ouzel
C++ game engine for Windows, macOS, Linux, iOS, tvOS, Android, and web browsers
Stars: ✭ 607 (+2790.48%)
Mutual labels:  glsl, hlsl
Crossshader
⚔️ A tool for cross compiling shaders. Convert between GLSL, HLSL, Metal Shader Language, or older versions of GLSL.
Stars: ✭ 113 (+438.1%)
Mutual labels:  glsl, hlsl
Pmtech
Lightweight, multi-platform, data-oriented game engine.
Stars: ✭ 478 (+2176.19%)
Mutual labels:  glsl, hlsl
Hlsl2glslfork
HLSL to GLSL language translator based on ATI's HLSL2GLSL. Used in Unity.
Stars: ✭ 488 (+2223.81%)
Mutual labels:  glsl, hlsl
Glslang
Khronos-reference front end for GLSL/ESSL, partial front end for HLSL, and a SPIR-V generator.
Stars: ✭ 2,034 (+9585.71%)
Mutual labels:  glsl, hlsl
Pmfx Shader
Cross platform shader system for HLSL, GLSL, Metal and SPIR-V.
Stars: ✭ 245 (+1066.67%)
Mutual labels:  glsl, hlsl

Inline SPIR-V

Crate Documentation

inline-spirv ease the way you write shaders. Although as game developers, we usually compile a permutation of shader stages for different objects and materials at runtime for the best flexibility; sometimes we do want to try out some new ideas and start up dirty. This crate helps you compile GLSL/HLSL shader in your Rust code, or in external files, into SPIR-V; and embed them right inside the binary, so you are freed from all the compilation hassle.

How to Use

To inline shader source:

use inline_spirv::include_spirv;

let spv: &'static [u32] = inline_spirv!(r#"
    #version 450 core
    void main() { gl_Position = vec4(0, 0, 0, 1); }
"#, vert);

To include a external shader source file:

use inline_spirv::include_spirv;

let spv: &'static [u32] = include_spirv!("assets/vert.hlsl", vert, hlsl, entry="Main");

For the full list of options please refer to the documentation.

Tips

The macro can be verbose especially you have a bunch of #includes, so please be aware of that you can alias and define a more customized macro for yourself:

use inline_spirv::include_spirv as include_spirv_raw;

macro_rules! include_spirv {
    ($path:expr, $stage:ident) => {
        include_spirv_raw!(
            $path,
            $stage, hlsl,
            entry="my_entry_pt",
            D VERBOSE_DEFINITION,
            D ANOTHER_VERBOSE_DEFINITION="verbose definition substitution",
            I "long/path/to/include/directory",
        )
    }
}

// ...
let vert: &[u32] = include_spirv!("examples/demo/assets/demo.hlsl", vert);

License

This project is licensed under either of

at your option.

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