Skip to content

Transpile shaders from one language to another using procedural macros.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

DraftedDev/transhader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tran(shader)

License Crates.io Downloads

Transpile shaders from one language to another using procedural macros.

Features

Functionality is split into different modules which allow you to transpile from/to any supported language. The default feature already includes all of them.

Supported Frontend Languages

  • from-glsl - Transpile OpenGL Shading Language (GLSL) Shaders.
  • from-spv - Transpile Standard Portable Intermediate Representation for Vulkan (SPIR-V) Shaders.
  • from-wgsl - Transpile Web GPU Shader Language (WGSL) Shaders.

Supported Backend Languages

  • to-glsl - Transpile shaders to OpenGL Shading Language (GLSL) Shaders.
  • to-msl - Transpile shaders to Metal Shading Language (MSL) Shaders.
  • to-spv - Transpile shaders to Standard Portable Intermediate Representation for Vulkan (SPIR-V) Shaders.
  • to-wgsl - Transpile shaders to Web GPU Shader Language (WGSL) Shaders.
  • to-hlsl - Transpile shaders to High Level Shader Language (HLSL) Shaders.

Why?

Some Multi-Backend Graphics APIs (like bgfx) require shaders for every backend (GLSL for OpenGL; HLSL for D3D; MSL for Metal; SPIR-V for Vulkan; WGSL for WebGPU). You can either try to transpile your shaders using naga during Runtime (which would affect performance) or transpile each shader using a build.rs script.

This tool simply transpiles shaders during compile-time without any hassle.

How?

Transhader uses naga and Rust's procedural macro system to generate optimal shader code. Configure shader transpiler options using the Rusty-Object-Notation.

Drawbacks

  • Limited shader language support.
  • Longer compile-times, since shaders are transpiled using procedural macros.
  • Less customization of transpiler options (though I am working on it).

License

Transhader is dual licensed under the MIT and Apache 2.0 licenses.

About

Transpile shaders from one language to another using procedural macros.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages