Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


ExtractFromScene

Extracts all relevant scene data for light transport calculations from the currently open scenes.
Read time 2 minutesLast updated 10 days ago

Definition

ExtractFromScene(BakeInput)

Extracts all relevant scene data for light transport calculations from the currently open scenes.
public static bool ExtractFromScene(out InputExtraction.BakeInput bakeInput)

Parameters

bakeInput

Output parameter that receives the extracted scene data.

Returns

Type

Description

boolTrue if extraction completed successfully, false if errors occurred.

Remarks

This method scans all currently open scenes and extracts objects that affect global illumination calculations. It processes:
Geometry:
  • MeshRenderer components with static flags or "Contribute GI" enabled.
  • Terrain objects with baked lighting enabled, including trees.
  • Associated Material properties and textures.
Lighting:
  • Light components configured for baked or mixed lighting.
  • Environment lighting and skybox settings.
  • Light probe groups (LightProbeGroup).
Output Data: The resulting BakeInput contains preprocessed data ready for InputExtraction.PopulateWorld. Objects not marked as static or not affecting GI are automatically excluded.
Performance Note: This operation can be expensive for large scenes as it processes all geometry and builds internal data structures.

Examples

// Extract scene data for bakingbool extractionSuccess = InputExtraction.ExtractFromScene(out var bakeInput);if (!extractionSuccess){ Debug.LogError("Failed to extract scene data for light baking"); return;}// Proceed with context creation and world populationusing var context = new RadeonRaysContext();context.Initialize();var world = new RadeonRaysWorld();using var progress = new BakeProgressState();bool populateSuccess = InputExtraction.PopulateWorld(bakeInput, progress, context, world);Assert.IsTrue(populateSuccess);

ExtractFromScene(BakeInput, bool)

Extracts all relevant scene data for light transport calculations from the currently open scenes.
public static bool ExtractFromScene(out InputExtraction.BakeInput bakeInput, bool probesOnly)

Parameters

bakeInput

Output parameter that receives the extracted scene data.

probesOnly

Whether to only extract data needed for baking probes. Setting this to false will skip lightmap packing.

Returns

Type

Description

boolTrue if extraction completed successfully, false if errors occurred.

Remarks

This method scans all currently open scenes and extracts objects that affect global illumination calculations. It processes:
Geometry:
  • MeshRenderer components with static flags or "Contribute GI" enabled.
  • Terrain objects with baked lighting enabled, including trees.
  • Associated Material properties and textures.
Lighting:
  • Light components configured for baked or mixed lighting.
  • Environment lighting and skybox settings.
  • Light probe groups (LightProbeGroup).
Output Data: The resulting BakeInput contains preprocessed data ready for InputExtraction.PopulateWorld. Objects not marked as static or not affecting GI are automatically excluded.
Performance Note: This operation can be expensive for large scenes as it processes all geometry and builds internal data structures.

Examples

// Extract scene data for bakingbool extractionSuccess = InputExtraction.ExtractFromScene(out var bakeInput);if (!extractionSuccess){ Debug.LogError("Failed to extract scene data for light baking"); return;}// Proceed with context creation and world populationusing var context = new RadeonRaysContext();context.Initialize();var world = new RadeonRaysWorld();using var progress = new BakeProgressState();bool populateSuccess = InputExtraction.PopulateWorld(bakeInput, progress, context, world);Assert.IsTrue(populateSuccess);