Glaze
Live shader coding for Ruby, from a saved file to a window, PNG, or WebGPU page.
Features · Installation · Quick Start · Shader Files
Glaze loads shader definitions written in Ruby, compiles them through RLSL, and renders them with RBGL. It supports live reload, headless output, parameter metadata, and WebGPU export.
Features
- Live reload for shader files without losing the current frame on a bad edit.
- CPU rendering for portable and headless workflows.
- Metal rendering and GPU pixel capture on supported macOS hosts.
- PNG screenshots, frame sequences, and standalone WebGPU HTML export.
- Typed parameters with defaults, ranges, steps, and an optional Twiddle panel.
- Built-in uniforms for time, frame, mouse, resolution, and fragment position.
Installation
Add Glaze to your Gemfile:
gem "glaze"Then run:
bundle installOr install the released gem:
gem install glazeRequirements
- Ruby 3.1 or newer.
- A C compiler for the CPU renderer and screenshot commands.
- Metal rendering requires macOS and a Metal-capable device.
Quick Start
Run the included examples:
glaze run examples/plasma.rb
glaze shot examples/plasma.rb --time 1.5 --size 640x360 -o shot.png
glaze record examples/plasma.rb --seconds 2 --fps 30 -o frames
glaze record examples/plasma.rb --seconds 2 --fps 30 --gif -o plasma.gif
glaze record examples/plasma.rb --seconds 2 --fps 30 --apng -o plasma.apng
glaze export examples/plasma.rb plasma.htmlglaze record writes PNG frames by default. The --gif and --apng options stream an animation through the optional Flipbook gem; with either option, -o names the output file.
Run a fixed number of headless CPU frames:
glaze run examples/plasma.rb --renderer cpu --backend file --frames 2 --output-dir framesShader files
A shader file contains one Glaze.shader definition:
Glaze.shader(:gradient) do
params do
float :speed, default: 1.0, range: 0.0..4.0
end
fragment do |point, resolution, uniforms|
value = point[0] / resolution[0] + uniforms.time * uniforms.speed
[value % 1.0, 0.2, 0.4, 1.0]
end
endFragments use rlsl syntax. Texture parameters are supported by the Metal runner; the WebGPU exporter embeds the referenced PNG bytes in its HTML.
Development
bundle install
bundle exec rake verifyContributing
Bug reports and pull requests are welcome at rbgfx/glaze.