Reference

Shaders

R3NE compiles shaders to Metal at runtime. The Shader node lets you drop your own Metal Shading Language (MSL) fragment into the graph and have it rebuild as you type.

Anatomy of a node shader

You write only the fragment body — the part that returns a float4 color. Declare parameters with // @input annotations at the top; R3NE parses them into inspector controls and connectable ports, then wraps your body in a full-screen pass.

metal
// @input float intensity 0.5 0.0 1.0
// @input float2 center 0.5 0.5
// @input texture src

float2 d = in.uv - center;
float r = length(d);
float pinch = 1.0 - intensity * exp(-r * r * 8.0);
return src.sample(texSampler, center + d * pinch);

The @input syntax

One annotation per line, at the top of the source. Each becomes a port and an inspector control. For a float, the two numbers after the default are the slider min and max — there is no separate range annotation.

metal
// @input float speed 2.0 0.0 20.0      // float: default, then min max
// @input float2 center 0.5 0.5         // x y
// @input float3 dir 0.0 1.0 0.0        // x y z
// @input float4 rect 0.0 0.0 1.0 1.0   // x y z w
// @input color tint 1.0 0.5 0.0 1.0    // r g b a (color picker)
// @input bool invert false             // checkbox
// @input texture noiseTex              // a texture input port

What the body gets

These are available inside the body without declaring them:

  • in.uvfloat2, normalized 0–1 UV.
  • in.positionfloat4, clip-space position.
  • u.time — seconds on the timeline (frozen when paused); u.wallTime always advances.
  • u.resolutionfloat2 render-target size in pixels.
  • u.mousefloat4, and u.transformfloat4x4.
  • texSampler — a predeclared linear / clamp-to-edge sampler. Sample any input texture with it.

Helper functions are allowed: declare them above the body and they’re hoisted above the fragment function automatically. Set the node’s Output Resolution (presets or a custom W×H) in the inspector.

Live recompile

  • Edit the shader in R3NE’s built-in editor; it rebuilds as you type.
  • Compile errors surface in the editor with line numbers; the last good pipeline keeps running so the output never goes black.
  • The same live-MSL approach powers pbrMaterial for 3D objects — there the body sets out.albedo, out.metallic, out.roughness and out.emission.

What’s next

  • Combine shaders with MCP to let a model author and tweak nodes from natural language.
  • Browse the node reference for the built-in effects you can chain around your shader.