# DynamicGI

> Query and control Enlighten Realtime Global Illumination.

## Definition

* **Type:** Class
* **Namespace:** [UnityEngine](/engine/6000.7/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
public sealed class DynamicGI
```

## Remarks

Use the [DynamicGI](/engine/6000.7/script-reference/unityengine/dynamicgi.md) static class to query and control the global Enlighten instance. Enlighten is a subsystem which provides Realtime Global Illumination. This class is applicable only when **Realtime Global Illumination** is enabled in the **Scene** tab of the **Lighting** window.

You can use this class to query the internal state of Enlighten. For example, you can use [DynamicGI.isConverged](/engine/6000.7/script-reference/unityengine/dynamicgi/isconverged.md) to determine whether to show a loading screen.

Some properties allow you to control the runtime cost of Enlighten. For example, you can use [DynamicGI.materialUpdateTimeSlice](/engine/6000.7/script-reference/unityengine/dynamicgi/materialupdatetimeslice.md) to determine how much computation is done every frame, and [DynamicGI.updateThreshold](/engine/6000.7/script-reference/unityengine/dynamicgi/updatethreshold.md) to control how often realtime lightmaps are updated.

Enlighten Realtime Global Illumination takes the assigned Skybox Material into account in its lighting calculations. In most situations, it detects and processes any changes to the Skybox Material automatically (for example, when you change the Skybox Material). However, there are situations when Enlighten can't detect the change automatically (for example, when the Skybox Material's shader depends on global variables such as system time). In this case, you can call [DynamicGI.UpdateEnvironment](/engine/6000.7/script-reference/unityengine/dynamicgi/updateenvironment.md) to manually schedule an evaluation of the current Skybox Material. You can also use [DynamicGI.SetEnvironmentData](/engine/6000.7/script-reference/unityengine/dynamicgi/setenvironmentdata.md) to skip the Skybox Material evaluation and pass in raw cubemap values instead.

For more information on Enlighten, refer to [Introduction to Realtime Global Illumination using Enlighten](https://docs.unity3d.com/Manual/realtime-gi-using-enlighten.html).

Additional Resources: [RendererExtensions.UpdateGIMaterials](/engine/6000.7/script-reference/unityengine/rendererextensions/updategimaterials.md), [TerrainExtensions.UpdateGIMaterials](/engine/6000.7/script-reference/unityengine/terrainextensions/updategimaterials.md).

## Examples

```csharp
using UnityEngine;

// Attach this script to a Game Object to animate the emission used
// by Enlighten Realtime GI. The Game Object's Material is unaffected.
public class AnimateEmission : MonoBehaviour
{
    public Color color1 = Color.red;
    public Color color2 = Color.blue;
    public float intensity = 2.0f;
    public float speed = 0.5f;

    void Update()
    {
        // This value changes gradually from 0 to 1 to 0 in a cycle.
        var pingpong = Mathf.PingPong(Time.time * speed, 1.0f);

        // Determine the new color for this frame.
        var newColor = Color.Lerp(color1, color2, pingpong) * intensity;

        // Extract the MeshRenderer from the game object.
        var renderer = gameObject.GetComponent<MeshRenderer>();

        // Apply the new emissive color using the MeshRenderer.
        DynamicGI.SetEmissive(renderer, newColor);
    }
}
```

## Static Methods

| Method                                                                                          | Description                                     |
| ----------------------------------------------------------------------------------------------- | ----------------------------------------------- |
| [UpdateEnvironment](/engine/6000.7/script-reference/unityengine/dynamicgi/updateenvironment.md) | Schedules an update of the environment cubemap. |
