Ray Kiln Plus, in your browser

GLSL to Metal

Paste a Shadertoy shader or GLSL and get Metal: a Ray Kiln shader that opens in the playground and runs in the Mac app, with anything that doesn’t convert named on its line. Try it free: see what converts and the picture it makes; the whole shader comes with Plus.

GLSL

      What it takes

      A Shadertoy shader’s Image tab (mainImage), a GLSL fragment shader with main and gl_FragCoord, or plain functions. Types, swizzles and constructors, matrices, out and inout parameters (Metal’s thread references), const arrays, structs, #define (with arguments too) and #if. GLSL’s mod, which differs from Metal’s fmod for negative numbers, comes along as a helper; atan(y, x) becomes atan2.

      Shadertoy’s inputs

      fragCoord is uv * u.resolution, from the bottom left as in Shadertoy. iTime is u.time, iResolution is float3(u.resolution, 1.0), iFrame is int(u.frame). iMouse.xy is the pointer in pixels (the middle of the picture until it moves); Ray Kiln has no clicks, so iMouse.zw is 0. A function that reads them is given u, and every call passes it on. A uniform float becomes a slider.

      What doesn’t convert

      Textures and iChannel0–3, so one pass only: Shadertoy’s buffers reach each other through iChannel. Also switch, global variables that change, and inverse. Each is named on its line, and the rest still converts. The result is checked by the translator the playground runs; the license of the shader you paste still applies to it.