Skip to main content
Shaders in Rive let you write custom WGSL programs that run on the GPU and render to a GPU canvas, which can then be drawn in your Rive file. They are useful for effects, procedural graphics, and visuals that go beyond what the vector renderer and standard Node scripts can produce. Rive shaders use standard WGSL, with some restrictions for compatibility across Rive’s supported rendering backends. See WGSL Support for supported features and limitations.
What’s a shader?A shader is a small program that runs on the GPU. GPUs are good at running the same program across many vertices or pixels in parallel, which makes shaders useful for graphics effects.A typical GPU pipeline uses two shader functions:
  • Vertex shader - decides where vertices are drawn.
  • Fragment shader - decides the color of each pixel covered by those vertices.

Creating a Shader

Create a new script, select WGSL Shader as the type, and name it BasicShader.
The AI Agent can be a helpful way to create or iterate on shader code. Describe the effect you want, then review and test the generated WGSL in your file.

Basic WGSL Shader

This shader draws a single large triangle that covers the render target. The parts of the triangle outside the render target are clipped, leaving the entire target covered. This is a common technique called a fullscreen triangle. The fragment shader then colors each pixel with a gradient. No vertex or index buffers are needed because the triangle’s vertices are defined directly in the shader.

Rendering a Shader with a Script

Uniforms

Uniforms pass values from a script into a shader, allowing the shader to respond to values that change at runtime. You can use uniforms for values such as colors, opacity, time, or animation parameters. Define the uniform data in your WGSL shader, then assign it to a bind group and binding. Bind groups organize the resources passed into a shader, while bindings identify individual resources within each group:
The shader can then use the uniform like any other value:
On the script side, create a GPUBuffer containing the uniform data and add it to a GPUBindGroup. The bind group and slot must match the @group and @binding values declared in the shader. Bind the group to the render pass before drawing. When a uniform changes, write the new value to its buffer to make it available to the shader. Uniform values can come from script inputs, allowing them to be configured in the Editor, animated, or controlled with data binding.

Shader Targets

Rive shaders are authored in WGSL. When you export your file, Rive compiles each shader for the selected targets and includes those variants in the .riv file. The original WGSL source isn’t included. When nothing is selected in the editor, the Inspector shows file-level Shader Targets options. Select the targets required by the runtimes and platforms where your file will be used:
  • Metal (MSL)
  • GLSL ES 300
  • WGSL
  • HLSL
  • SPIR-V
The WebGPU backend uses WGSL directly. If a target is not selected, the shader isn’t included for that backend and won’t load when the file runs on it.

WGSL Support

Rive uses standard WGSL with some restrictions to ensure shaders work across supported rendering backends. Rive supports vertex and fragment shaders, with up to four bind groups. Compute shaders and override declarations aren’t supported. Some WGSL features are also unavailable, including 64-bit float and integer types, push constants, subgroup operations, and non-uniform resource indexing.