Vixen
02b45cc4
csharp
public sealed class VfxDocument

An effect, open for editing as a graph, with a simulation running beside it.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Doc 20's E5 opens with "VFX graph reachable", and reachable is the whole of what was missing. The node library, the compiler and both targets were written for VfxGraphCompiler and tested — what did not exist was a document, a factory and a registration, so nothing in the editor could turn a double-click into an effect. This is that, and it is the same shape CompositorDocument already had.

⚠ The file holds the graph, not the compiled effect. A .vxvfx is a NodeGraphAsset — nodes, edges, positions, the numbers an author typed — and Compile turns it into the VfxCompiledGraph a simulation runs and the shader a device runs. Saving the compiled form would throw away the layout and make the document unopenable; saving both would be two files that can disagree.

⚠ The preview is a real simulation, not an approximation of one. Preview is a VfxSystem over the artefact this document just produced, stepped by the panel — the same class a game runs. What the editor cannot yet do is draw particles the way a game does, because that is a material and doc 14's Phase 7 owns it; so VfxPreviewView projects the buffer itself and says what it is showing. The half that would be wrong to fake is the simulation, and it is not faked.

⚠ A file this build cannot read opens empty and says why. NodeGraphDocument.Load repairs what it can and refuses a graph from a later version outright; both arrive in LoadDiagnostics rather than as an exception, so the panel that could show the problem is reachable.

Fields and properties (8)

  • public const string Extension

    What a VFX graph is written as.

  • public string AssetPath

    Where the file is, absolute.

  • public NodeGraphModel Graph

    The graph.

  • public NodeTypeRegistry Registry

    The node types this document is edited against.

  • public IReadOnlyList<NodeDiagnostic> LoadDiagnostics

    What reading the file had to say — repairs, and a refusal.

  • public IReadOnlyList<NodeDiagnostic> Diagnostics

    What the last Compile had to say.

  • public VfxGraphArtefact? Artefact

    What the last Compile produced, or .

  • public VfxSystem? Preview

    The simulation the preview steps, or until one compiles.

Events (1)

  • public Action<VfxDocument>? Compiled

    Raised after Compile has run.

Methods (7)

  • public VfxDocument(EditorProject project, AssetId asset, string path, NodeTypeRegistry? registry = null)

    Opens an effect graph.

  • public VfxGraphArtefact? Compile()

    Compiles the graph, and restarts the preview over what came out.

  • public void Restart()

    Starts the preview again from nothing, keeping the compiled effect.

  • public string ToYaml()

    The graph as this document would write it, without writing it.

  • public string? ShaderSource()

    The compute shader the graph emits, for a host that wants the GPU half.

  • protected override void SaveCore()

    Writes the document back to wherever it came from.

  • protected override void OnClosed()

    Called once when the document leaves the project.

Used by (3)

  • AuthoringTestsVixen.Editor.AssetEditors.Tests
  • VfxEditorFactoryVixen.Editor.AssetEditors
  • VfxGraphViewVixen.Editor.AssetEditors