> 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/tools-and-shipping/performance-guide.md).

# Performance Guide

## Main-Thread Cost

Typical main-thread cost is under `0.1 ms` because brightness analysis uses `AsyncGPUReadback`.

The plugin avoids synchronous GPU readback during normal runtime processing.

The work is split into:

* GPU blit to downsample and convert to luminance
* Async GPU readback of a small grayscale texture
* CPU averaging when the readback is complete
* GPU blit to apply the current exposure multiplier

## Downsample Factor

`downsampleFactor` controls how much the source image is reduced before analysis.

| Factor | 1080p Analysis Size | Pixels Analyzed | Recommended For           |
| -----: | ------------------- | --------------: | ------------------------- |
|    `4` | 480 x 270           |         129,600 | Desktop and high accuracy |
|    `8` | 240 x 135           |          32,400 | Mobile balance            |
|   `16` | 120 x 68            |           8,160 | Low-end devices           |

Brightness is a low-frequency image property, so high analysis resolution is usually unnecessary.

## Readback Frame Skip

`readbackFrameSkip` controls how often brightness is measured.

| Value | Behavior                  |
| ----: | ------------------------- |
|   `0` | Analyze every frame       |
|   `2` | Analyze every third frame |
|   `4` | Analyze every fifth frame |

For most live camera or video content, `2` is a good default.

The exposure value still interpolates every frame, so increasing this value reduces measurement frequency without making the final blit update less often.

## Mobile Starting Point

For mobile builds:

* `downsampleFactor`: `8`
* `readbackFrameSkip`: `4`
* `targetBrightness`: `0.4`
* `maxExposure`: `3.0`

Use Vulkan on Android when possible. OpenGL ES readback behavior is more driver-dependent.

## Static UI Textures

For `AutoExposureRawImage` and `AutoExposureImage` on static content:

* Leave `Continuous Update` disabled.
* Use `ForceUpdate()` after changing settings.
* Avoid processing the same static texture every frame.

For webcam, video, or changing render textures, enable `Continuous Update` or call the core component manually each frame.

## Mask Cost

Masked processing reads back both the downsampled brightness texture and a downsampled mask. Use masks when they improve the exposure target, especially for subject-focused scenes, but avoid them when whole-frame metering already works.

## Preset Guidance

| Scenario                | Suggested Settings                                           |
| ----------------------- | ------------------------------------------------------------ |
| Desktop webcam          | `downsampleFactor = 4`, `readbackFrameSkip = 2`              |
| Mobile webcam           | `downsampleFactor = 8`, `readbackFrameSkip = 4`              |
| Low-end mobile          | `downsampleFactor = 16`, `readbackFrameSkip = 5`             |
| Fast lighting changes   | Lower `readbackFrameSkip`, raise `adjustmentSpeed` carefully |
| Flicker or noisy source | Lower `adjustmentSpeed`, raise `readbackFrameSkip`           |

## WebGL

WebGL uses the synchronous brightness fallback. Increase `downsampleFactor` and `readbackFrameSkip` to reduce the cost on analysis frames.


---

# 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/tools-and-shipping/performance-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.
