Peios Learn
Documentation

Peios

Peios Peios Kernel Universal Directory Project

Developer Tools

Trail Acta Provium clackatoo CAF GCSL Pekit

Applications

Framewright

Standards and Conventions

Standards and Conventions Peios Specifications
Framewright

Framewright

A photo and video editor for montages cut to music.

Single-page view · as markdown

Framewright

Framewright / Getting Started

Framewright Studio is a photo and video editor for montages: long sequences of photos and video clips cut to music. It brings photo editing, video editing and compositing into one application, with light 3D for titles and effects.

A project holds a media library and any number of documents. Each document has a kind, such as video or photo, and the kind decides which workspaces it offers. To work on one kind of content inside another, you step into a nested container instead of switching applications. For example, a video clip opens into its own node graph on the Compose page.

Framewright is early in development. This documentation grows as features are built.

Shader Nodes

Framewright / Plugins

A shader node is a node you write yourself as a short GPU program, without rebuilding Framewright. It lives in a folder that holds two files: a manifest that names the node and lists its inputs and parameters, and a function body in the WebGPU Shading Language (WGSL) that works out one pixel. Framewright's own Exposure, Saturation, Invert, Vignette, and Mix nodes are shader nodes, built the same way.

If you have written a DCTL for DaVinci Resolve or a BlinkScript kernel for Nuke, a shader node will be familiar: a small function, run for every pixel on the GPU, whose parameters appear as controls.

How a shader node runs #

Framewright runs the function once for every pixel of every frame. The function sees one pixel of each input, all at the same position, and returns the pixel the node outputs. It can't read neighboring pixels, so a shader node can change color and combine images but can't blur or distort them.

Framewright joins neighboring per-pixel steps into one GPU pass. A chain of shader nodes, together with the color conversions around it, reads and writes each pixel once, so a shader node costs about as much as the arithmetic it does.

The manifest and the shader's text are part of the key of every cached frame the node contributes to. Editing either file changes those keys, so Framewright never shows a frame made with an older version of the shader.

What the function sees #

The shader file holds the inside of a function. Before its first line, Framewright declares names for the pixel, the inputs, and the parameters that the manifest lists:

NameWGSL typeHolds
cvec4<f32>The pixel from the first input
Each other input's idvec4<f32>The pixel from that input
Each parameter's idSet by the parameter's typeThe parameter's value at this frame
posvec2<f32>The pixel's center, in canvas units
framevec4<f32>The image's edges: left, top, right, bottom

The function returns a vec4<f32>: the pixel the node outputs. To get a position that runs from 0 to 1 across the image, divide pos - frame.xy by frame.zw - frame.xy, as the built-in Vignette does.

Each parameter type arrives in the shader as a WGSL type:

Type in the manifestWGSL typeValue
floatf32The number
inti32The whole number
boolbooltrue or false
choicei32The position of the option picked, counting from 0
vec2vec2<f32>The two numbers
colorvec4<f32>Red, green, blue, and alpha, in the working color space

Color and alpha #

Every input pixel arrives in Framewright's working color space, ACEScg, from the Academy Color Encoding System (ACES). ACEScg holds scene-linear light: doubling a value doubles the light, and values above 1.0 are ordinary highlights rather than errors. Framewright converts each input to ACEScg before the node, and converts the node's output on to wherever it goes next.

Pixels are premultiplied: their red, green, and blue are already multiplied by their alpha. Scaling red, green, and blue together works directly on a premultiplied pixel and leaves its edges clean. A curve, such as a gamma, needs the unpremultiplied color, so divide by alpha first and multiply by it again after.

A color parameter is the exception. It arrives unpremultiplied, converted to the working color space, with its alpha in the fourth component.

Where Framewright finds plugins #

A plugin folder is any folder that holds a plugin.toml. Framewright reads plugins in this order:

  1. Its built-in shader nodes.
  2. Each plugin folder in ~/.local/share/framewright/plugins. If the XDG_DATA_HOME environment variable is set, Framewright uses $XDG_DATA_HOME/framewright/plugins instead.
  3. Each plugin folder in each folder that FW_PLUGIN_PATH lists, separated by colons. A folder in the list can also be a plugin folder itself.

Every node type needs its own id. If a plugin uses an id that Framewright has already loaded, Framewright skips the plugin and reports it, so a plugin can't replace a built-in node.

Changes while Framewright runs #

Framewright watches its plugin folders. When you save a file in one, it reads every plugin again within about a second and renders the viewer again. Frames that don't involve a changed plugin stay in the cache.

Errors #

Framewright reports plugin problems in the bar at the bottom of the window, and on the standard error stream when it was started from a terminal:

  • A manifest that can't be read. Framewright skips the plugin and reports what is wrong with the manifest.
  • A shader with an error. Framewright still loads the node, so projects that use it keep it. The report gives the line and column in the shader file, and rendering the node shows the same error in the viewer. Saving a fixed shader clears the report.
  • A plugin that isn't installed. A project that uses its node keeps the node and its settings, saves them unchanged, and reports the node as unavailable when rendering. After you install the plugin, open the project again to use the node.

What a shader node can't do #

A shader node:

  • Reads only the pixel at its own position in each input
  • Has one image output, and needs at least one image input
  • Holds its whole program in the function body, without functions of its own

Writing a Shader Node

Framewright / Plugins

This page builds a Tint node as a shader plugin: a node that multiplies the image by a color, with a control for how strongly. When you finish, Tint is in Framewright's node library, and editing a text file changes what it does. Shader Nodes explains what a shader node can do and what its function receives.

Before you start #

You need:

  • Framewright, with a graph or a clip to try the node on
  • A text editor

Knowing some WGSL helps, but this page doesn't depend on it.

Create the plugin #

  1. Create a folder for the plugin:

    mkdir -p ~/.local/share/framewright/plugins/tint
    
  2. In that folder, create plugin.toml with this content:

    id = "example.tint"
    version = 1
    name = "Tint"
    category = "Filter"
    
    [[params]]
    id = "tint"
    name = "Tint"
    type = "color"
    default = [1.0, 0.6, 0.3]
    
    [[params]]
    id = "amount"
    name = "Amount"
    type = "float"
    unit = "percent"
    default = 50
    range = [0, 100]
    limits = [0, 100]
    

    The manifest names the node, puts it in the library's Filter group, and gives it two parameters. range sets what the slider covers, and limits sets the values Framewright accepts. The manifest reference lists every key. Every node type needs its own id, so start yours with a prefix of your own and a dot; the built-in nodes use fw..

  3. In the same folder, create shader.wgsl with this content:

    // Multiply the image by the tint color, then blend by the amount.
    let tinted = c.rgb * tint.rgb;
    return vec4<f32>(mix(c.rgb, tinted, amount / 100.0), c.a);
    

    c is the pixel from the node's input. Each parameter is available by its id: tint is a vec4<f32> and amount is an f32.

If Framewright is running, it loads the plugin within about a second of the save. Otherwise it loads the plugin when it starts.

Add the node #

  1. Open the graph you want to tint on the Compose page. For a clip on the timeline, select the clip and press Enter.
  2. Move the pointer over an empty part of the node editor and press Tab.
  3. Enter tint and press Enter. Tint appears where the library opened.
  4. Drag from the output port of the node that feeds Output to the input port of Tint.
  5. Drag from the output port of Tint to the input port of Output. The connection replaces the one that was there.

Check the result #

The viewer shows the image with a warm tint. Select Tint in the node editor: the inspector shows an orange swatch for Tint and a slider for Amount at 50.0%. Drag Amount to 100.0% and the image takes on the full tint.

Change the shader #

Framewright reads a plugin again whenever one of its files changes, so you can work on the shader with the viewer open:

  1. In shader.wgsl, change tint.rgb to tint.bgr.
  2. Save the file.

Within about a second, the viewer shows the image with a cool tint instead, because the shader swaps the tint's red and blue.

Read an error #

When the shader has an error, Framewright still loads the node and reports where the error is. To see one, change the second line to multiply by tint rather than tint.rgb:

let tinted = c.rgb * tint;

When you save, the bar at the bottom of the window shows the error, and the viewer shows it over the image:

/home/<user-name>/.local/share/framewright/plugins/tint: its shader doesn't work: shader.wgsl:2:14: Operation Multiply can't work with vec3<f32> and vec4<f32>

Here user-name is your user name. shader.wgsl:2:14 is the line and column where the error starts. c.rgb has three components and tint has four, so WGSL can't multiply them. Change tint back to tint.rgb and save: the error clears and the tint returns.

Shader Node Manifest

Framewright / Plugins

A shader plugin's plugin.toml names the node, points at its shader, and lists its image inputs and parameters. Framewright reads it when it loads the plugin and refuses a manifest with a missing key, an unknown key, or a value of the wrong type, reporting which one.

The node #

The top level of the manifest describes the node:

KeyTypeRequiredMeaning
idStringYesThe node type's id, which projects save. It must contain a dot, as in example.tint.
versionWhole numberYesStarts at 1.
nameStringYesThe name in the node library and on the node.
categoryStringYesThe library group the node appears in, such as Filter.
shaderStringNoThe shader file, relative to the plugin folder. The default is shader.wgsl.
varies_with_timeBooleanNoWhether the output changes over time even with constant parameters. The default is false.
inputsArray of tablesNoThe node's image inputs, written as [[inputs]] tables.
paramsArray of tablesNoThe node's parameters, written as [[params]] tables.

Every node has one image output.

Keep version at 1. Framewright can't open a project saved with an older version of a plugin node, because a shader plugin has no way to convert the parameters such a project saved. A project saved with a newer version than the one installed keeps the node unchanged, and reports it as unavailable when rendering.

When varies_with_time is true, Framewright renders the node again at every frame instead of reusing one result while its inputs and parameters stay the same. The shader receives no time value, so set the key only when something the shader reads varies over time in a way Framewright can't see.

Inputs #

Each [[inputs]] table adds an image input, in order:

KeyTypeMeaning
idStringThe name the shader reads the input by, and the name projects save its connection under
nameStringThe label on the node's port

A node needs at least one input. Without an [[inputs]] table, it has one called image, labeled Image. The shader reads the first input as c, whatever its id, and every other input by its id.

Parameters #

Each [[params]] table adds a parameter. The inspector shows parameters in the order the manifest lists them:

KeyTypeRequiredMeaning
idStringYesThe name the shader reads the value by, and the name projects save it under
nameStringYesThe label in the inspector
typeStringYesOne of the parameter types in the table of types
defaultDepends on typeNoThe value of a new node
unitStringNoHow the value is shown, for float and vec2
rangeTwo numbersNoThe span the slider of a float covers
limitsTwo numbersNoThe values Framewright accepts for a float, vec2, or color, checked on each component
sectionStringNoThe inspector section the parameter appears in. Without one, it's in the section named after the node.
animatableBooleanNoWhether the value can change over time with keyframes
optionsArray of tablesFor choiceThe choices, each with an id and a name

A value outside range is still allowed, as long as it is within limits. A default outside limits makes the manifest invalid. Parameters are animatable by default, except choices.

Parameter types #

Each type takes its default in its own form:

TypedefaultWithout a defaultIn the shader
floatA number0f32
intA whole number0i32
booltrue or falsefalsebool
choiceThe id of one optionThe first optioni32, the position of the option picked, counting from 0
vec2Two numbers, [x, y][0, 0]vec2<f32>
colorThree or four numbers, [r, g, b] or [r, g, b, a], in linear Rec.709[0, 0, 0, 1]vec4<f32>, unpremultiplied, in the working color space

A choice parameter declares its options like this:

[[params]]
id = "mode"
name = "Mode"
type = "choice"
default = "screen"
options = [
  { id = "multiply", name = "Multiply" },
  { id = "screen", name = "Screen" },
]

The shader reads mode as 0 for Multiply and 1 for Screen. Projects save the option's id, so you can reorder or add options without changing what saved projects mean.

Units #

The unit key takes one of these values:

ValueShown as
none0.500, a plain number (the default)
pixels12.0 px
degrees45.0°
seconds1.500 s
decibels-6.0 dB
stops1.00 EV, stops of exposure
ratio1.500×
percent50.0%

Ids #

Input and parameter ids become names in the shader, so they follow these rules:

  • They use lowercase letters, digits, and underscores, and start with a letter.
  • They don't repeat each other: no parameter shares an id with an input or with another parameter.
  • They avoid the names Framewright declares around the shader: c, pos, frame, base, prm, params, src, dst, and main, any name made of e or ex followed by digits, and any name starting with fw_ or op_.
  • They avoid WGSL keywords and type names, such as let, fn, f32, and vec4.

Peios Learn — documentation for Peios software.

Built with Trail.