Ruby GLSL · WGSL · MSL · C

Ruby syntax.
GPU reach.

Write a shader once with familiar Ruby constructs. RLSL infers its types and emits source for the graphics API your project needs.

  • Targets04
  • Ruby≥ 3.1
  • LicenseMIT
plasma.rb RLSL source
uniforms do
  float :time
end

fragment do |coord, size, u|
  uv = coord / size

  red = sin(u.time + uv.x * 6.28)
  blue = sin(u.time + uv.y * 6.28)

  vec3(red * 0.5 + 0.5, uv.y, blue)
end
compiled field fragment output

01 / Workflow

One source.
Four native outputs.

RLSL keeps the authoring loop in Ruby while producing shader source that belongs in each target ecosystem.

  1. 01

    Describe

    Use blocks, helper functions, uniforms, vectors, matrices, and familiar control flow.

  2. 02

    Infer

    RLSL parses the Ruby source with Prism, resolves shader types, and validates the program.

  3. 03

    Emit

    Generate source for OpenGL, WebGPU, Metal, or a C target for CPU rendering.

02 / Authoring

Keep shader logic readable.

Shader code stays close to the Ruby application that owns it. Declare uniforms once, name helper signatures explicitly, and choose the target at the call site.

Read the usage guide
Ruby GLSL WGSL MSL
# The same block can target three GPU languages.
shader = RLSL.to_wgsl(:pulse) do
  uniforms do
    float :time
  end

  fragment do |coord, resolution, u|
    uv = coord / resolution
    wave = sin(u.time + uv.x * TAU)
    vec3(uv.x, uv.y, wave * 0.5 + 0.5)
  end
end

03 / Targets

Meet the renderer where it is.

Source generation is platform-independent. Choose the output that fits the host.

GLSL

OpenGL Shading Language

Desktop and cross-platform graphics pipelines.

RLSL.to_glsl

WGSL

WebGPU Shading Language

Modern GPU rendering for the web and native WebGPU hosts.

RLSL.to_wgsl

MSL

Metal Shading Language

Source generation for Apple's Metal graphics stack.

RLSL.to_msl

C

Native CPU target

Compile and run the shader as a Ruby C extension for CPU rendering.

RLSL.define

04 / Install

From gem to first shader.

RLSL supports Ruby 3.1 and newer. Install it, require it, and start with one fragment block.

gem install rlsl