RLSL

Ruby Like Shading Language

Ruby syntax. GPU reach.

Write shaders with Ruby constructs. RLSL infers types and emits GLSL, WGSL, MSL, or C.

gem install rlsl

INPUT · RUBYfragment { ... }
→
GLSL · WGSLMSL · C
One shader definitionRuby → GLSL · WGSL · MSL · C

Author once. Choose the output.

Keep shader logic with the Ruby app, then select a target at the call site.

01

Write in Ruby

Declare uniforms and express fragment logic with Ruby blocks.

02

Infer shader types

Use vector operations and inferred variable types.

03

Target four outputs

Generate GLSL, WGSL, Metal Shading Language, or C source.

A small first step

Start with one example.

Install the gem, then follow the project guide for platform requirements and the full API.

Read the installation guide ↗

require "rlsl"

shader = RLSL.to_wgsl(:pulse) do
  uniforms { float :time }
  fragment do |coord, resolution, u|
    uv = coord / resolution
    wave = sin(u.time + uv.x * 6.28)
    vec3(uv.x, uv.y, wave * 0.5 + 0.5)
  end
end