Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/GraphiteEditor/Graphite/llms.txt

Use this file to discover all available pages before exploring further.

Graphene is the name of the underlying procedural graphics engine that powers Graphite. Instead of storing artwork as fixed pixel data or static shapes, Graphene compiles and executes node networks — directed acyclic graphs that describe how artwork is generated from inputs. Every piece of artwork in Graphite is ultimately the output of a node network evaluation, which is re-run whenever an input changes. This procedural approach makes all edits non-destructive by design.

Node Networks

A node network is a finite set of nodes connected together as a directed acyclic graph (DAG). Data flows through the network from left to right: nodes receive typed inputs from the nodes connected to them and produce typed outputs that flow to the next nodes. To interact with the outside world, a network has import connectors (data flowing in from the enclosing context) and export connectors (data flowing out). From outside, a network is a black box — it is fed inputs and can be executed to produce outputs. The root-level network in a document exports to the canvas; subgraph networks may receive an image as input, process it, and export the result. In the Graphene codebase, the term “network” is used instead of “graph” or “subgraph” to avoid ambiguity with user-facing concepts. There is nothing structurally different between a root network and any subgraph — both are instances of NodeNetwork.

Key Crates

The Graphene engine is spread across several crates in the node-graph/ directory of the workspace:

graph-craft

Defines the core document types: NodeNetwork, DocumentNode, NodeInput, NodeId, and ProtoNetwork. Also contains the Compiler struct that transforms a NodeNetwork into a flat ProtoNetwork ready for execution.

interpreted-executor

Provides DynamicExecutor, which takes a ProtoNetwork and evaluates it at runtime using dynamic dispatch. Caches node outputs to avoid redundant re-evaluation when only a portion of the graph changes.

node-macro

The #[node_macro::node] proc-macro crate. Annotate a Rust function with this attribute to define a custom node: the macro generates the type registration, input/output connector wiring, and the node executor boilerplate.

graphene-core (gcore)

Fundamental types and traits shared across all nodes. Contains Context, NodeIO, NodeIOTypes, and the memo/monitor infrastructure. Every node crate depends on this.

graphene-std (gstd)

Standard library of utility nodes: rendering infrastructure, web request nodes, animation timing, and rendering pipeline utilities like RenderConfig and ExportFormat.

wgpu-executor

WGPU-based GPU executor. Manages the GPU device, context, and shader execution pipeline. Raster shader nodes compile to SPIRV and run through this executor.
Additional node crates in node-graph/nodes/ provide domain-specific nodes: vector, raster, graphic, transform, math, repeat, blending, text, and brush.

Core Type Structures

The central types in graph-craft that represent a document-level network are:
/// An instance of a node definition placed in a network.
pub struct DocumentNode {
    /// Inputs: connections from other nodes, constant values, or imports
    pub inputs: Vec<NodeInput>,
    /// The type of argument this node is evaluated with
    pub call_argument: Type,
    /// Either a nested NodeNetwork (subgraph) or a ProtoNode identifier (native node)
    pub implementation: DocumentNodeImplementation,
    /// Whether this node is visible (hidden nodes become passthrough)
    pub visible: bool,
}

/// The possible inputs to a node.
pub enum NodeInput {
    /// A connection from another node in the same network
    Node { node_id: NodeId, output_index: usize },
    /// A hardcoded constant value
    Value { tagged_value: MemoHash<TaggedValue>, exposed: bool },
    /// Data imported from the parent network
    Import { .. },
}
A NodeNetwork is a map from NodeId to DocumentNode, plus metadata about the network’s imports, exports, and UI positioning.

Compilation Pipeline

Before a network can be executed, it must be compiled to a flat ProtoNetwork. The pipeline is:
1

Source NodeNetwork

The document stores a NodeNetwork with fully nested subgraphs, NodeInput::Import connectors, and UI metadata.
2

Preprocessing

The preprocessor crate expands subgraph nodes inline, resolving resource hashes and flattening the hierarchy.
3

Compiler (graph-craft)

The Compiler::compile_single method transforms the preprocessed network into a ProtoNetwork — a flat list of ProtoNode entries with all connections resolved to node IDs.
4

DynamicExecutor (interpreted-executor)

DynamicExecutor::new(proto_network) constructs the runtime executor. Calling executor.execute(context) runs the network and returns a TaggedValue result.
You can inspect the compiled proto-network for any .graphite document using graphene-cli:
graphene-cli compile --print-proto my-artwork.graphite

Node Types

Graphene supports two kinds of nodes, both represented uniformly as DocumentNode in the network: Native nodes are implemented directly in Rust, annotated with #[node_macro::node]. The macro registers them with a ProtoNodeIdentifier string so the compiler can resolve them by name at compile time. Subgraph nodes are implemented as nested NodeNetwork instances inside the DocumentNode.implementation field. Double-clicking a subgraph node in the Graphite editor reveals its interior network. Many of the built-in Graphite nodes are subgraphs composed from simpler native nodes.

GPU Acceleration

Graphene includes a WGPU-based GPU execution path for raster operations. Shader nodes are compiled from Rust using spirv-std to SPIRV shaders and executed on the GPU via the wgpu-executor crate. The GPU path is used automatically for raster image processing nodes when a compatible GPU is available. The wgpu-executor crate manages the WGPU device and queue. Raster textures are represented as Raster<GPU> and can be converted back to CPU buffers (Raster<CPU>) for encoding to PNG/JPG output.
GPU shader nodes require SPIRV compilation and are only available on native targets (not WebAssembly without WebGPU). The #[node_macro::node(..., shader_node(...))] attribute instructs the macro to generate both a CPU fallback and a GPU shader variant.
For information on writing your own nodes, see Node Development. To use the Graphene engine from the command line, see graphene-cli.

Build docs developers (and LLMs) love