GLSL
OpenGL Shading Language
Desktop and cross-platform graphics pipelines.
RLSL.to_glsl
Ruby GLSL · WGSL · MSL · C
Write a shader once with familiar Ruby constructs. RLSL infers its types and emits source for the graphics API your project needs.
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
01 / Workflow
RLSL keeps the authoring loop in Ruby while producing shader source that belongs in each target ecosystem.
Use blocks, helper functions, uniforms, vectors, matrices, and familiar control flow.
RLSL parses the Ruby source with Prism, resolves shader types, and validates the program.
Generate source for OpenGL, WebGPU, Metal, or a C target for CPU rendering.
02 / Authoring
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# 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
Source generation is platform-independent. Choose the output that fits the host.
OpenGL Shading Language
Desktop and cross-platform graphics pipelines.
RLSL.to_glsl
WebGPU Shading Language
Modern GPU rendering for the web and native WebGPU hosts.
RLSL.to_wgsl
Metal Shading Language
Source generation for Apple's Metal graphics stack.
RLSL.to_msl
Native CPU target
Compile and run the shader as a Ruby C extension for CPU rendering.
RLSL.define
04 / Install
RLSL supports Ruby 3.1 and newer. Install it, require it, and start with one fragment block.
gem install rlsl