Scene Export Manifest and Commandlet
The scene export commandlet exports scenes to Simplygon .sgscene files outside the editor, for example on a build machine or as a step in a processing pipeline. A scene export manifest describes what to export. You build the manifest in the editor or in a headless editor process, and the commandlet later uses it to export the scenes in a separate process:
- Build a manifest with
USimplygonSceneExportManifestBuilder: add scenes of actors or static meshes, optionally with landscape clipping geometry and scene captures, and save it to a file. - Run the commandlet with the manifest. It loads the referenced worlds and assets, exports each scene, and writes a receipt next to each
.sgscenefile. - Start processing when a receipt appears. The receipt describes the exported scene, so processing can be set up without opening the
.sgscenefile.
The manifest stores references to saved content, such as actor GUIDs and level packages, together with the export settings to use. Treat the manifest file as opaque and create it with the builder.
Note
The scene export manifest and commandlet build on the Export API, which is experimental. Function calls and settings may change in upcoming releases. See Known issues and limitations.
Build a manifest
The builder is available from C++, Python, and Blueprint. See the API references for C++, Python, and Blueprint.
Each scene has a unique name, an output .sgscene file, a source, and export settings that are passed as-is to the Export API when the scene is exported. A scene has one of these sources:
- Actors: the static mesh components of saved actors in one world. Add them with
AddActorScene, or from a World Partition world without loading the actors withAddActorSceneFromWorldPartitionActors. - Static mesh: a single saved static mesh asset, added with
AddStaticMeshScene.
Actor scenes can also have:
- Landscape clipping geometry:
AddLandscapeClippingadds the landscape inside the scene's bounds to the clipping geometry selection set. UseAddLandscapeGeometryAppendfor full control of the landscape settings and bounds. - Scene captures:
AddSplatterCasterCapturerenders the scene's components from cameras around them, set up for a splatter caster. UseAddSceneCapturefor full control of the camera generation and capture settings. See Managed Scene Export and Capture for these settings. By default, a capture renders preview copies of the components in an isolated preview world. Pass theExistingcapture world to render the components in their own world without duplicating them. The components are rendered at full draw distance, and at LOD 0 when the scene settings force it, and restored after the capture. All captured channels are material attributes rendered without lighting, so they don't depend on the world's lights in either capture world. An existing-world capture fails, instead of waiting, if another capture is using the components.
Every add validates its input, so the builder always holds a valid manifest. The commandlet checks the references again when it exports, since content can change after the manifest was built. SaveToFile writes the manifest atomically. LoadFromFile reads a manifest back, for example to inspect or extend it.
Important
The manifest only references saved content, so save worlds and assets before building a manifest. Actors without a persistent actor GUID, actors that have never been saved, and actors inside a Level Instance that is being edited can't be added.
C++
C++ functions return SG::FTaskResult. All builder functions are synchronous and must be called on the game thread.
#include "ImportExport/Export/Manifest/SimplygonSceneExportManifestBuilder.h"
TStrongObjectPtr<USimplygonSceneExportManifestBuilder> Manifest(USimplygonSceneExportManifestBuilder::Create());
const FString OutputFile = FPaths::ProjectSavedDir() / TEXT("Simplygon/ManifestExample/SelectedActors.sgscene");
auto AddResult = Manifest->AddActorScene(TEXT("SelectedActors"), OutputFile, SelectedActors, ExportSettings);
if (AddResult.HasError())
{
UE_LOG(LogTemp, Error, TEXT("%s"), *AddResult.GetError().Message);
return;
}
const bool bAllowEmpty = true;
auto ClippingResult =
Manifest->AddLandscapeClipping(TEXT("SelectedActors"), ELandscapeCullingPrecision::Medium, bAllowEmpty);
if (ClippingResult.HasError())
{
UE_LOG(LogTemp, Error, TEXT("%s"), *ClippingResult.GetError().Message);
return;
}
auto SaveResult = Manifest->SaveToFile(ManifestFilePath);
if (SaveResult.HasError())
{
UE_LOG(LogTemp, Error, TEXT("%s"), *SaveResult.GetError().Message);
}Keep the builder referenced, for example with TStrongObjectPtr, across anything that can run garbage collection, such as loading a map.
Python
Python functions raise a RuntimeError with the reason on failure.
# Example for building a scene export manifest that a scene export commandlet can process later.
def scene_export_manifest_example(mesh_path, manifest_file_path):
"""Example for describing selected actors and a static mesh as scenes in a scene export manifest."""
# Actors must be saved in a saved map, since the manifest references them by actor GUID and level package.
EAS = unreal.get_editor_subsystem(unreal.EditorActorSubsystem)
selected_actors = EAS.get_selected_level_actors()
manifest = unreal.SimplygonSceneExportManifestBuilder.create()
output_directory = unreal.Paths.project_saved_dir() + "Simplygon/ManifestExample/"
# Paths are stored as absolute paths. Relative paths follow the Unreal convention, like the ones from unreal.Paths.
# Failures raise a RuntimeError with the reason.
manifest.add_actor_scene(
"SelectedActors",
output_directory + "SelectedActors.sgscene",
selected_actors,
get_default_scene_export_settings(True),
)
# Adds landscape geometry inside the bounds of the selected actors as clipping geometry.
# allow_empty lets the export succeed when no landscape intersects the actors.
manifest.add_landscape_clipping(
"SelectedActors", unreal.LandscapeCullingPrecision.MEDIUM, allow_empty=True
)
manifest.add_static_mesh_scene(
"Mesh",
output_directory + "Mesh.sgscene",
get_static_mesh_from_path(mesh_path),
get_default_mesh_export_settings(True),
)
manifest.save_to_file(manifest_file_path)
unreal.log(
f"Scene export manifest with scenes {list(manifest.get_scene_names())} saved to {manifest_file_path}"
)See Python Examples for a World Partition example.
Blueprint
Blueprint functions have True and False execution pins. On False, call Get Last Error Message on the builder for the reason. See Blueprint Examples.
World Partition worlds
A World Partition world can be too large to load in full. GetManifestWorldPartitionActors lists the actors of a World Partition world from World Partition's saved actor descriptors without loading any actors, and AddActorSceneFromWorldPartitionActors adds a scene from them. The listed actors include the actors in every placement of the world's Level Instances, including nested ones.
The filter skips actors that can't be exported by default: World Partition HLOD actors, editor-only actors, Level Instance actors (the actors inside them are listed instead), and landscapes (add them with AddLandscapeClipping instead). Each listed actor has its saved editor bounds, which you can use to split the world into several scenes, for example one per grid cell.
Actor descriptors are written when actors are saved, so save the world before building the manifest. Actors with unsaved changes are captured as last saved, and loaded actors that have never been saved are an error.
Export the scenes
Run the commandlet with the editor's command line executable:
UnrealEditor-Cmd.exe <ProjectPath> -run=SimplygonSceneExport -Manifest=<ManifestPath> -AllowCommandletRendering -Unattended| Argument | Description |
|---|---|
-Manifest=<path> | Manifest file to export. Relative paths are relative to the process base directory. |
-Scenes=<name>,<name> | Comma-separated names of the scenes to export. Defaults to all scenes. Scenes are exported in manifest order. |
-ResolveOnly | Loads and resolves the scenes and logs counts, time, and memory, without exporting anything. |
-GCEvery=<N> | Collects garbage after every N scenes. Defaults to 0, which collects only after a world is unloaded. |
-CleanStaging | Deletes the staging directories in the output directories of the selected scenes before exporting. Don't use it while other exports write to the same directories. |
Exporting bakes materials and renders scene captures, so the commandlet requires rendering: pass -AllowCommandletRendering and don't pass -nullrhi. -ResolveOnly runs without rendering.
The commandlet loads the referenced content as it was last saved. Scenes are independent: a scene that fails is reported in the log and the remaining scenes are still exported. The exit code is 0 when every selected scene was exported, and 1 when the arguments or the manifest are invalid or any scene failed.
Actors that are found but have nothing to export, such as hidden actors, are skipped and reported in the receipt. Actors that can't be found, for example because they were deleted, fail the scene.
Consume the output
Each scene is written to a .sgexport-staging directory in its output directory and moved to its output file once it is complete. The receipt is written after that and marks the scene as complete, so start processing when the receipt appears, never on the .sgscene file. By default the receipt is written next to the output file, as <output file without extension>.receipt.json.
The receipt is a JSON file with these fields:
| Field | Description |
|---|---|
schemaVersion | Version of the receipt format. Currently 1. |
sceneName | Name of the scene in the manifest. |
sceneFile | Absolute path of the exported .sgscene file. |
sourceType | Actors or StaticMesh. |
worldOffset | World offset added to the exported geometry. Subtract it to place processed results back in the world. Zero when no offset is used and for static mesh scenes. |
exportedComponentCount | Number of static mesh components exported into the scene. Zero for static mesh scenes. |
selectionSets | Selection sets in the scene with geometry, such as landscape clipping, with their node count. A set whose geometry was allowed to be empty is not in the scene and not listed. Scene capture camera sets are listed under sceneCaptures. |
sceneCaptures | Scene captures rendered into the scene, with their camera selection set name, camera count, image dimensions, captured buffer types, and the achieved pixels per world unit. |
warnings | Issues that didn't fail the export, for example landscape clipping that found no landscape. |
resolution | What resolving the actors found: requested and resolved actor counts, skipped actors with reasons, component and instance counts, and actors whose label or path changed since the manifest was built. Empty for static mesh scenes. |
exportSeconds | Time spent exporting and saving the scene. |
A shortened receipt of a scene with a splatter caster capture:
{
"schemaVersion": 1,
"sceneName": "Cell_X0_Y0",
"sceneFile": "D:/Project/Saved/Simplygon/ManifestWorldPartitionExample/Cell_X0_Y0.sgscene",
"sourceType": "Actors",
"worldOffset": { "x": 0, "y": 0, "z": 0 },
"exportedComponentCount": 10,
"selectionSets": [],
"sceneCaptures": [
{
"name": "SplatterCaster",
"cameraSelectionSetName": "SplatterCasterCameraSet",
"cameraCount": 8,
"captureImageDimensions": { "x": 1024, "y": 1024 },
"bufferTypes": 129,
"pixelsPerUnit": { "x": 0.17, "y": 0.17 }
}
],
"warnings": [],
"resolution": { "requestedActorCount": 10, "resolvedActorCount": 10, ... },
"exportSeconds": 4.2
}For example, when the receipt lists the clipping geometry selection set with a node count above zero, enable clipping geometry in the processing pipeline. When it lists a splatter caster scene capture, set up a splatter caster with the receipt's camera selection set.
