Skip to content

Add support for white parameter to AgX tonemapper (Mk. 2)#102425

Closed
allenwp wants to merge 1 commit intogodotengine:masterfrom
allenwp:agx-add-white-param-mk2
Closed

Add support for white parameter to AgX tonemapper (Mk. 2)#102425
allenwp wants to merge 1 commit intogodotengine:masterfrom
allenwp:agx-add-white-param-mk2

Conversation

@allenwp
Copy link
Copy Markdown
Contributor

@allenwp allenwp commented Feb 4, 2025

Not cherry-pickable to 4.3, as AgX is only in 4.4.

Also limits white parameter from being set lower than 0.01 in the editor.

Draft State

I am intentionally leaving this PR in a draft state because I expect that the performance characteristics are not be suitable for merging this into Godot. Additionally, documentation must be further updated in this PR if it was to be merged.

Usage

In addition to resolving issues with using AgX with the Mobile renderer, the white parameter can be used to give higher contrast by decreasing white. This approach is higher quality than using the Environment's contrast adjustment and does not significantly affect the brightness of the scene like the previous incorrect approach.

16.0 white (Forward+) 2.0 white (Forward+)
image image

Consistent rendering between Mobile and Forward+

Because the Mobile renderer only provides values to the tonemapper up to 2.0, you can achieve a similar appearance with AgX between the Mobile and Forward+ renderers by setting the white paramter to 2.0 or less. This makes it easier to use AgX on a cross-platform game that must use the Mobile renderer on some platforms, but uses the Forward+ renderer on others.

Limitations

The white parameter does not function below values of 1.172, so this parameter is clipped to this minimum in EnvironmentStorage.

Performance

Using the visual profiler, Calinou's tonemapping test scene, ~4K window, and an NVIDIA 980 Ti on Windows 11, I recorded the following performance stats:

AgX (this PR): 1.35 ms
Tony McMapface: 1.29 ms
AgX (exact, hardcoded white): 1.22 ms
AgX (Godot 4.4 beta 2): 1.19 ms
ACES: 1.07 ms
Filmic: 1.0 ms
Rienhard: 0.93 ms
Linear: 0.82 ms

Fixes godotengine#101558 and godotengine#102416
Also limits white parameter from being set lower than 0.01 in the editor.
@allenwp
Copy link
Copy Markdown
Contributor Author

allenwp commented May 21, 2025

I discovered that this approach does not work well with HDR output and variable Extended Dynamic Range (EDR) output.

I have drafted a new work in progress prototype that demonstrates a new tonemapping curve for AgX that includes a white parameter: #106696

Please try it out and leave feedback on that PR!

@allenwp
Copy link
Copy Markdown
Contributor Author

allenwp commented May 29, 2025

Superseded by #106940, which gives stable behaviour across all variable / extended dynamic range (EDR), HDR, and SDR.

@allenwp allenwp closed this May 29, 2025
@AThousandShips AThousandShips removed this from the 4.x milestone May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AgX: Oscillations in sigmoid approximation AgX has low dynamic range output with Mobile renderer

3 participants