vvvv gamma Fundamentals
What Is vvvv gamma
vvvv gamma is a visual programming environment for .NET 8. It combines node-based patching with C# code generation, targeting Stride (3D engine) and .NET APIs. Programs are built by connecting nodes with links in a visual editor.
vvvv is a live programming environment — programs run continuously while you build them. Both visual patch edits and C# code changes take effect immediately without restarting. vvvv compiles C# source files itself via Roslyn into in-memory assemblies on every save.
Document Structure
- -
.vl files — vvvv gamma documents (XML-based, version controlled) - Each document contains Patches (visual programs) and Definitions (types, operations)
- Documents can reference NuGet packages and other
.vl files - The Patch Explorer shows the document's type hierarchy
Execution Model
- - Frame-based evaluation — the mainloop evaluates the entire graph every frame (~60 FPS)
- Data flows left-to-right, top-to-bottom through links between nodes
- Process nodes maintain state between frames (constructor → Update loop → Dispose)
- Operation nodes are pure functions evaluated each frame
- vvvv evaluates all connected nodes, skips disconnected subgraphs
Live Compilation Model
vvvv runs your program continuously while you edit it. There is no edit-compile-run cycle for patches and shaders. For C#, live reload depends on how the code is referenced.
Patch Changes
- - Edits to visual patches apply immediately
- Node state (instance fields) is preserved across edits
- New nodes and links become active on the next frame
Shader Changes
- -
.sdsl shader files always live-reload when saved - vvvv recompiles shaders in the background and swaps them in the running program
C# — Two Workflows
C# code can be integrated via source project reference or pre-compiled binary. The choice depends on project size and development phase.
Source project reference (live reload):
When a .vl document references a .csproj source project, vvvv compiles .cs files itself via Roslyn into in-memory assemblies. No dotnet build or external toolchain is involved.
- - On .cs file save, vvvv detects the change and recompiles in the background
- Status indicator: gray = building symbols, orange = emitting C#
- On successful compilation, affected nodes restart their lifecycle:
1.
Dispose() called on old instance
2. New constructor runs (with fresh
NodeContext)
3.
Update() resumes on the next frame
- - Static fields reset on reload — the entire in-memory assembly is replaced
- On compilation error, the program continues running with the last valid code
Binary reference (no live reload):
When a .vl document references a pre-compiled DLL or NuGet package, the assembly is loaded once at startup. To pick up changes, you must rebuild the DLL externally (e.g., dotnet build) and restart vvvv. This workflow is common for larger projects and stable libraries where live reload is not needed.
Node Categories
Process Nodes
- - Have Create (constructor), Update (per-frame), and Dispose lifecycle
- Written in C# with
[ProcessNode] attribute - Maintain internal state between frames
- Use change detection to avoid redundant work
Operation Nodes
- - Pure functions: same input always produces same output
- Written as static C# methods (auto-discovered by vvvv)
- No state between frames
- No
[ProcessNode] attribute needed
Adaptive Nodes
- - Nodes that adapt their implementation based on connected input types
- Example:
+ works with int, float, Vector3, string, etc. - Resolved at link-time, not runtime
Pins, Pads, and Links
- - Pins — inputs and outputs on nodes and regions
- Pads — visual nodes for reading/writing Properties inside operation patches; all pads with the same name refer to the same property
- Links — connections between pins that define data flow and execution order
- Spreading — when a
Spread<T> connects to a single-value input, the node auto-iterates
When to Patch vs Write C#
| Use Patching | Use C# Code |
|---|
| Prototyping, data flow | Custom nodes, performance-critical code |
| Visual connections, UI composition |
Complex algorithms |
| Real-time parameter tweaking | .NET library interop |
| Dataflow routing and spreading | Native/unmanaged resource management |
Channels — Reactive Data Flow
- -
IChannel<T> — observable value container - INLINECODE13 — read/write the current value
- INLINECODE14 — check if connected
- Channels persist state across sessions
- Enable two-way data binding between UI and patch
For C# channel integration patterns (IChannelHub, PublicChannelHelper, [CanBePublished]), see vvvv-channels.
Key Data Types
| Type | C# Equivalent | Usage |
|---|
| INLINECODE15 | INLINECODE16 | vvvv's immutable collection |
| INLINECODE17 |
ImmutableArray<T>.Builder | Build spreads efficiently |
| Float32, Int32, etc. |
float,
int | Primitives |
|
Vector2/3/4 |
Stride.Core.Mathematics | Spatial math |
|
Color4 |
Stride.Core.Mathematics | RGBA color |
File Types
| Extension | Purpose |
|---|
| INLINECODE25 | vvvv gamma documents (XML-based) |
| INLINECODE26 |
Stride shader files (SDSL language) |
|
.cs | C# source files for custom nodes |
|
.csproj | .NET project files |
|
.nuspec | NuGet package spec |
Ecosystem Overview
vvvv's functionality extends through NuGet packages that bundle .vl documents, C# nodes, and shaders.
| Domain | Key Packages |
|---|
| 3D Rendering | VL.Stride (Stride engine), VL.Fuse (GPU visual programming) |
| 2D Rendering |
VL.Skia, ImGui, Avalonia, CEF/HTML |
| Hardware I/O | DMX/Art-Net, ILDA lasers, depth cameras (Azure Kinect, ZED), robotics (KUKA, Spot), Ultraleap, LiDAR |
| Networking | OSC, MIDI, MQTT, Redis, WebSocket, HTTP, TCP/UDP, ZeroMQ, Modbus, Ableton Link |
| Computer Vision | OpenCV, MediaPipe, YOLO (v8–v11), ONNX Runtime |
| Audio | NAudio, VST hosting, SuperCollider bridge |
| General .NET | Any of 100,000+ standard NuGet packages via .csproj reference |
To add a package: reference it in your .vl document's Dependencies, or add a <PackageReference> to your .csproj. See vvvv-dotnet for .csproj details.
AppHost & Runtime Detection
CODEBLOCK0
For detailed reference, see reference.md.
技能名称: vvvv-基础
vvvv gamma 基础
什么是 vvvv gamma
vvvv gamma 是一个面向 .NET 8 的可视化编程环境。它将基于节点的连线式编程与 C# 代码生成相结合,主要针对 Stride(3D 引擎)和 .NET API。程序通过在可视化编辑器中用连线连接节点来构建。
vvvv 是一个实时编程环境——在构建程序的同时,程序会持续运行。无论是可视化补丁编辑还是 C# 代码更改,都会立即生效,无需重启。vvvv 会在每次保存时通过 Roslyn 自行将 C# 源文件编译为内存中的程序集。
文档结构
- - .vl 文件 — vvvv gamma 文档(基于 XML,支持版本控制)
- 每个文档包含补丁(可视化程序)和定义(类型、操作)
- 文档可以引用 NuGet 包和其他 .vl 文件
- 补丁资源管理器显示文档的类型层次结构
执行模型
- - 基于帧的求值 — 主循环每帧(约 60 FPS)对整个图形进行求值
- 数据从左到右、从上到下通过节点之间的连线流动
- 处理节点在帧之间保持状态(构造函数 → 更新循环 → 释放)
- 操作节点是每帧求值的纯函数
- vvvv 会求值所有已连接的节点,跳过未连接的子图
实时编译模型
vvvv 在您编辑程序时持续运行它。补丁和着色器没有编辑-编译-运行的循环。对于 C#,实时重载取决于代码的引用方式。
补丁更改
- - 对可视化补丁的编辑会立即生效
- 节点状态(实例字段)在编辑之间保持不变
- 新节点和连线将在下一帧激活
着色器更改
- - .sdsl 着色器文件在保存时始终会实时重载
- vvvv 在后台重新编译着色器,并在运行的程序中替换它们
C# — 两种工作流程
C# 代码可以通过源项目引用或预编译二进制文件集成。选择取决于项目规模与开发阶段。
源项目引用(实时重载):
当 .vl 文档引用 .csproj 源项目时,vvvv 会通过 Roslyn 自行将 .cs 文件编译为内存中的程序集。无需 dotnet build 或外部工具链。
- - 保存 .cs 文件时,vvvv 检测到更改并在后台重新编译
- 状态指示器:灰色 = 构建符号,橙色 = 生成 C#
- 编译成功后,受影响的节点会重启其生命周期:
1. 对旧实例调用 Dispose()
2. 运行新的构造函数(使用新的 NodeContext)
3. 在下一帧恢复 Update()
- - 静态字段在重载时重置——整个内存中的程序集被替换
- 编译出错时,程序将继续使用最后一个有效代码运行
二进制引用(无实时重载):
当 .vl 文档引用预编译的 DLL 或 NuGet 包时,程序集在启动时加载一次。要获取更改,您必须在外部重新构建 DLL(例如 dotnet build)并重启 vvvv。此工作流程适用于不需要实时重载的大型项目和稳定库。
节点类别
处理节点
- - 具有 Create(构造函数)、Update(每帧)和 Dispose 生命周期
- 使用 [ProcessNode] 属性以 C# 编写
- 在帧之间保持内部状态
- 使用变更检测避免冗余工作
操作节点
- - 纯函数:相同的输入始终产生相同的输出
- 编写为静态 C# 方法(由 vvvv 自动发现)
- 帧之间无状态
- 不需要 [ProcessNode] 属性
自适应节点
- - 根据连接的输入类型调整其实现的节点
- 示例:+ 适用于 int、float、Vector3、string 等
- 在连线时解析,而非运行时
引脚、焊盘和连线
- - 引脚 — 节点和区域上的输入和输出
- 焊盘 — 用于在操作补丁内读取/写入属性的可视化节点;所有同名的焊盘都引用同一个属性
- 连线 — 引脚之间的连接,定义数据流和执行顺序
- 扩散 — 当 Spread 连接到单值输入时,节点会自动迭代
何时使用补丁与编写 C#
| 使用补丁 | 使用 C# 代码 |
|---|
| 原型设计、数据流 | 自定义节点、性能关键代码 |
| 可视化连接、UI 组合 |
复杂算法 |
| 实时参数调整 | .NET 库互操作 |
| 数据流路由和扩散 | 原生/非托管资源管理 |
通道 — 响应式数据流
- - IChannel — 可观察的值容器
- IChannel.Value — 读取/写入当前值
- Channel.IsValid() — 检查是否已连接
- 通道在会话之间保持状态
- 支持 UI 和补丁之间的双向数据绑定
有关 C# 通道集成模式(IChannelHub、PublicChannelHelper、[CanBePublished]),请参阅 vvvv-channels。
关键数据类型
| 类型 | C# 等效类型 | 用途 |
|---|
| Spread<T> | ImmutableArray<T> | vvvv 的不可变集合 |
| SpreadBuilder<T> |
ImmutableArray
.Builder | 高效构建 Spread |
| Float32、Int32 等 | float、int | 基本类型 |
| Vector2/3/4 | Stride.Core.Mathematics | 空间数学 |
| Color4 | Stride.Core.Mathematics | RGBA 颜色 |
文件类型
| 扩展名 | 用途 |
|---|
| .vl | vvvv gamma 文档(基于 XML) |
| .sdsl |
Stride 着色器文件(SDSL 语言) |
| .cs | 自定义节点的 C# 源文件 |
| .csproj | .NET 项目文件 |
| .nuspec | NuGet 包规范 |
生态系统概览
vvvv 的功能通过 NuGet 包扩展,这些包捆绑了 .vl 文档、C# 节点和着色器。
| 领域 | 关键包 |
|---|
| 3D 渲染 | VL.Stride(Stride 引擎)、VL.Fuse(GPU 可视化编程) |
| 2D 渲染 |
VL.Skia、ImGui、Avalonia、CEF/HTML |
| 硬件 I/O | DMX/Art-Net、ILDA 激光、深度相机(Azure Kinect、ZED)、机器人(KUKA、Spot)、Ultraleap、LiDAR |
| 网络 | OSC、MIDI、MQTT、Redis、WebSocket、HTTP、TCP/UDP、ZeroMQ、Modbus、Ableton Link |
| 计算机视觉 | OpenCV、MediaPipe、YOLO(v8–v11)、ONNX Runtime |
| 音频 | NAudio、VST 宿主、SuperCollider 桥接 |
| 通用 .NET | 通过 .csproj 引用 100,000 多个标准 NuGet 包中的任意一个 |
要添加包:在您的 .vl 文档的依赖项中引用它,或者向您的 .csproj 添加一个 。有关 .csproj 的详细信息,请参阅 vvvv-dotnet。
AppHost 与运行时检测
csharp
// 检测是作为导出的 .exe 运行还是在编辑器中运行
bool isExported = nodeContext.AppHost.IsExported;
// 注册每个应用程序的单例服务
nodeContext.AppHost.Services.RegisterService(myService);
有关详细参考,请参阅 reference.md。