Skip to content

v0.10.0: The Shader Object

This is the first release of FragmentColor.

FragmentColor is a universal GPU abstraction layer where you can simply write some WGSL or GLSL code, forget about pipeline setup, set uniforms by key-value, and it will render on every device in existence. That’s it.

This version is a full rewrite of the original PLRender engine from Pupil Labs, removing every module and keeping only three simple objects: the Shader, the Renderer, and the Target.

The central idea behind FragmentColor is runtime shader reflection. The shader code dictates the structures around it, and there is no need for you to think about buffer layouts and manual pipeline setup; you can just set your uniforms with the dot notation using the same name you declared in the shader itself:

let shader = Shader::new("shader source defining my_uniform");
shader.set("my_uniform", 0.5);
renderer.render(shader);

Feel free to read the docs for more details.

Install it on your favorite platform with:

Terminal window
cargo add fragmentcolor
npm install fragmentcolor
pip install fragmentcolor

FragmentColor aims to be the simplest GPU abstraction API in existence: being both simpler and more powerful than OpenGL. It builds on top of wgpu and abstracts away all the low-level boilerplate.

The core is minimalist on purpose. Only a few basic types (Shader, Pass, Texture, Renderer, Target, Vertex, and Mesh) can combine into anything you want to build or quickly prototype.

We’re also keeping up with wgpu and naga as they evolve, the WebGPU standards, and the WASM ecosystem. Every time there is a new API change or new upstream capability, we aim to implement it as quickly as possible and make the abstraction around it automated and minimal.

  • The Renderer API draws heavily from pygfx, a beautiful Python rendering engine that aims at a higher level than us. It is closer to Three.js for Python, with its own scene graph and renderable objects. FragmentColor uses pygfx’s RenderCanvas abstraction for the Python render surface.

  • The Shader-centric design came from Pupil Labs, as stated in our origin story.

  • Some of the GPU optimization techniques were inspired by Ruffle Flash Player engine.

  • Although most of the old code did not survive the full refactor, I owe most of my learning to kwark’s (the wgpu contributor) and his minimalistic prototype engine Baryon.

  • And, of course, nobody starts their wgpu journey without passing through the fantastic Learn Wgpu series by Ben Hansen.

— Rafael