> For the complete documentation index, see [llms.txt](https://morningheartgames.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://morningheartgames.gitbook.io/docs/asyncautoexposure/runtime-usage/component-guide.md).

# Component Guide

## AsyncAutoExposure

`AsyncAutoExposure` is the core runtime component.

Use it when you want to process any `Texture` manually from code.

```csharp
var exposure = gameObject.AddComponent<AsyncAutoExposure>();
RenderTexture corrected = exposure.ProcessTexture(sourceTexture);
```

### Inspector Fields

| Field                | Range            |     Default | Description                                                                                                        |
| -------------------- | ---------------- | ----------: | ------------------------------------------------------------------------------------------------------------------ |
| Auto Exposure Shader | Any `Shader`     | Auto-loaded | Leave empty to load `Resources/Shaders/AutoExposure`. Assign manually only for a custom luminance/exposure shader. |
| Target Brightness    | `0.1` to `1.0`   |       `0.4` | Average output brightness the plugin aims for.                                                                     |
| Adjustment Speed     | `0.1` to `5.0`   |       `4.0` | How quickly current exposure eases toward target exposure.                                                         |
| Min Exposure         | `0.3` to `2.0`   |       `0.5` | Lowest allowed exposure multiplier.                                                                                |
| Max Exposure         | `0.5` to `100.0` |       `3.0` | Highest allowed exposure multiplier.                                                                               |
| Downsample Factor    | `1+`             |         `4` | Divides the analysis resolution. Higher values are faster and less precise.                                        |
| Readback Frame Skip  | `0` to `10`      |         `2` | Frames skipped between brightness readbacks.                                                                       |

### Inspector Presets

The custom Inspector includes quick presets:

| Preset           | Use                                                      |
| ---------------- | -------------------------------------------------------- |
| Low Light        | Dark sources that need more lift                         |
| Balanced         | General webcam/video default                             |
| Bright Source    | Bright inputs that should not be over-amplified          |
| High Performance | Larger downsample and lower readback frequency           |
| High Quality     | Smaller downsample and more frequent readback            |
| Reset            | Restore package defaults and reset exposure in Play Mode |

### Runtime Monitor

In Play Mode, the Inspector shows:

* Measured brightness
* Applied exposure and target exposure
* Output texture size

## AutoExposureRawImage

`AutoExposureRawImage` processes a Unity UI `RawImage`.

Use it for:

* Webcam previews
* Video render textures
* Runtime camera feeds
* UI panels displaying a texture

Important fields:

| Field                  |      Default | Description                                                                                     |
| ---------------------- | -----------: | ----------------------------------------------------------------------------------------------- |
| Auto Exposure          | Auto-created | Reference to an `AsyncAutoExposure` component. If empty, one is created on the same GameObject. |
| Enable Auto Exposure   |       `true` | Main toggle.                                                                                    |
| Consider Alpha Channel |       `true` | Transparent pixels can be ignored during analysis.                                              |
| Continuous Update      |      `false` | Enable for live sources.                                                                        |
| Alpha Threshold        |        `0.1` | Pixels below this alpha are ignored.                                                            |

### Behavior

* The original `RawImage.texture` is cached.
* The component processes the original texture, then assigns `autoExposure.OutputTexture` back to the `RawImage`.
* If an external script swaps the source texture, the component detects the change and refreshes.
* Alpha masking uses the bundled `AlphaExtract` shader when the texture format supports alpha.

### Public Methods

```csharp
void ForceUpdate();
void ResetToOriginal();
```

Use `ForceUpdate()` after changing settings on a static image. Use `ResetToOriginal()` when you want to restore the unprocessed source texture.

## AutoExposureImage

`AutoExposureImage` targets Unity UI `Image` components.

Use it when working with sprites rather than raw textures.

Unlike `AutoExposureRawImage`, it does not draw the corrected result back through the original `Image`. It processes the sprite texture and displays the result in an assigned `RawImage`.

Important fields:

| Field                  |      Default | Description                                                            |
| ---------------------- | -----------: | ---------------------------------------------------------------------- |
| Auto Exposure          | Auto-created | Reference to an `AsyncAutoExposure` component.                         |
| Enable Auto Exposure   |       `true` | Main toggle.                                                           |
| Consider Alpha Channel |       `true` | Opaque sprite pixels drive the brightness calculation.                 |
| Continuous Update      |      `false` | Keep disabled for static sprites unless the sprite changes repeatedly. |
| Alpha Threshold        |        `0.1` | Sprite pixels below this alpha are ignored.                            |
| Output Raw Image       |       `null` | Required display target for the corrected texture.                     |

### Public Methods

```csharp
void ForceUpdate();
float GetCurrentBrightness();
```

`GetCurrentBrightness()` performs a one-off brightness check using the current sprite texture. When alpha-aware metering is enabled, the sprite texture must be readable because the component extracts alpha values on the CPU.

## Choosing The Right Component

| Need                                               | Use                                           |
| -------------------------------------------------- | --------------------------------------------- |
| Process a webcam or video texture in custom code   | `AsyncAutoExposure`                           |
| Add correction to a `RawImage` without custom code | `AutoExposureRawImage`                        |
| Correct a sprite from a UI `Image`                 | `AutoExposureImage` plus an output `RawImage` |
| Meter only the subject or foreground               | `ProcessTextureWithMask()`                    |
| Meter only visible UI pixels                       | Enable `Consider Alpha Channel`               |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://morningheartgames.gitbook.io/docs/asyncautoexposure/runtime-usage/component-guide.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
