# PopulateWorld(BakeInput, BakeProgressState, IDeviceContext, IWorld)

> Converts extracted scene data into optimized data structures for light transport calculations.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine.LightTransport](/engine/6000.0/script-reference/unityengine/lighttransport.md)
* **Assembly:** UnityEditor

```csharp
public static bool PopulateWorld(InputExtraction.BakeInput bakeInput, BakeProgressState progress, IDeviceContext context, IWorld world)
```

### Parameters

**** (\[BakeInput]\(/engine/6000.0/script-reference/unityengine/lighttransport/inputextraction/bakeinput)): Scene data extracted using [InputExtraction.ExtractFromScene](/engine/6000.0/script-reference/unityengine/lighttransport/inputextraction/extractfromscene.md).**** (\[BakeProgressState]\(/engine/6000.0/script-reference/unityengine/lighttransport/bakeprogressstate)): Progress tracking object for monitoring world population status.**** (\[IDeviceContext]\(/engine/6000.0/script-reference/unityengine/lighttransport/idevicecontext)): Device context that will be used for light transport calculations.**** (\[IWorld]\(/engine/6000.0/script-reference/unityengine/lighttransport/iworld)): World object to populate with the processed scene data.

### Returns

| Type                                                          | Description                                                                |
| ------------------------------------------------------------- | -------------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True if world population completed successfully, false if errors occurred. |

### Remarks

This method transforms the raw scene data from BakeInput into optimized data structures suitable for ray tracing and light integration. The process includes:

**Data Processing:**

* Building spatial acceleration structures (BVHs) for fast ray intersection.
* Uploading geometry data to device memory.
* Preprocessing materials and textures.
* Setting up light data structures for efficient queries.

**Device Compatibility:**

The populated world is optimized for the specific device context:

* GPU contexts: Data uploaded to GPU memory with optimized layouts.
* CPU contexts: Data organized for SIMD processing and cache efficiency.

**Performance Impact:**

This operation can take significant time for complex scenes as it involves:

* Geometry preprocessing and optimization.
* Memory allocations and data transfers.
* Acceleration structure construction.
* Shader compilation (on first use).

The populated world can be reused across multiple integrators for efficiency.

### Examples

```csharp
// Complete workflow: extract scene data and populate world
bool extractResult = InputExtraction.ExtractFromScene(out var bakeInput);
Assert.IsTrue(extractResult, "Scene extraction failed");

// Create device context and world
using var context = new RadeonRaysContext();
bool initResult = context.Initialize();
Assert.IsTrue(initResult, "Failed to initialize RadeonRays context");

var world = new RadeonRaysWorld();

// Set up progress monitoring
using var progress = new BakeProgressState();
progress.SetTotalWorkSteps(1000); // Estimate based on scene complexity

// Populate world with extracted data
bool populateResult = InputExtraction.PopulateWorld(bakeInput, progress, context, world);

if (!populateResult)
{
    Debug.LogError("Failed to populate world with scene data");
    return;
}

// World is now ready for integration operations
var integrator = new RadeonRaysProbeIntegrator();
integrator.Prepare(context, world, probePositions, 0.1f, 2);

// Proceed with lighting calculations
var result = integrator.IntegrateDirectRadiance(context, 0, probeCount, 1024, false, outputBuffer);
```
