Skip to content

Repository files navigation

Glaze

Live shader coding for Ruby, from a saved file to a window, PNG, or WebGPU page.

Gem Version Downloads Ruby Version License

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 install

Or install the released gem:

gem install glaze

Requirements

  • 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.html

glaze 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 frames

Shader 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
end

Fragments 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 verify

Contributing

Bug reports and pull requests are welcome at rbgfx/glaze.

License

MIT

About

Live Ruby shader authoring with CPU and Metal rendering, frame capture, and WebGPU export.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages