Skip to main content
Shaders are currently only available in Early Access. Runtime support is either in development or available as experimental builds.Have feedback? Join the Early Access community to share your thoughts and help shape the feature.
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.
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 Asset

Create a new script, select 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. 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 points are defined directly in the shader. Basic gradient shader preview

Rendering the Shader with a Script

How It Works

context:shader

context:shader("BasicShader") retrieves the compiled shader asset by name. The name must match the shader asset in your file.

GPUCanvas

context:gpuCanvas() creates the render target the shader draws into. The canvas exposes its rendered result as canvas.image.

GPUPipeline

GPUPipeline.new() combines the shader with render settings such as vertex layout and color target format.

drawCanvas

Use drawCanvas for GPU rendering. This is where you begin a render pass, set the pipeline, and issue draw calls.

draw

Use draw to draw the rendered canvas image into the Rive scene.

Shader Targets

When nothing is selected in the editor, the Inspector shows file-level Shader Targets options. Use these options to choose which shader languages Rive should generate from your WGSL shaders:
  • Metal (MSL)
  • GLSL ES 300
  • HLSL
  • SPIR-V
Enable the targets required by the runtimes and platforms where your file will be used. Shader Targets options in the Inspector