Skip to content

vista-art/fragmentcolor

Repository files navigation

FragmentColor

FragmentColor is a Creative Coding library written in Rust that provides a simple shader programming API for Javascript and Python, with more language bindings in the horizon.

This library uses wgpu as the hardware abstraction layer, which enables us to target a wide range of platforms and environments with near-native performance and small footprint:

Backend WASM Linux MacOS Windows Android iOS CI / CD
Metal no no Yes no no Yes no
Vulkan no Yes Yes1 Yes Yes Yes Yes
OpenGL no Yes Yes2 Yes Yes Yes3 no
WebGL Yes4 no no no no no no
WebGPU Yes no no no no no no
Dx11/Dx12 no no no Yes no no no

Warning

This library is currently under heavy development, and the API is not yet stable, meaning that while it is not tagged 1.0.0, I might introduce breaking changes in minor versions. You can use it and test it, and I would greatly appreciate any feedback you can provide. If you use it in production, make sure you know what you are doing and lock the minor version.

Building this project

Target: web browser / wasm

Make sure you have wasm-pack installed.

cd crates/fragmentcolor-wasm
wasm-pack build --release --target web

The library will be available in pkg/.

Check the usage example in index.html.

Target: desktop window

Building all:

cargo task build all

Building:

cd crates/fragmentcolor
cargo build --release

The dynamic library will be available in target/release/.

By default, the library will be built for the current platform. To build for a specific platform, use the --target flag:

# MacOS (Intel)
cargo build --release --target x86_64-apple-darwin

# MacOS (Apple Silicon)
cargo build --release --target aarch64-apple-darwin

# Linux
cargo build --release --target x86_64-unknown-linux-gnu

# Windows
cargo build --release --target x86_64-pc-windows-msvc

You can check the list of all available targets with:

rustup target list

Platform support is divided in Tiers, check the Rust Platform Support page for more information.

Footnotes

  1. Available through MoltenVK, a translation layer to Metal.

  2. OpenGL is deprecated in MacOS. It runs up to version 4.1 only: no support for Compute shaders.

  3. OpenGL is deprecated in iOS. It runs up to version 4.1 only: no support for Compute shaders.

  4. Vertex and Fragment shaders only. No support for Compute shaders.