1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00
Commit Graph

25 Commits

Author SHA1 Message Date
clayjohn
2e59cb41f4 Optimize glow and tonemap gather step in the mobile renderer
Mobile devices are typically bandwidth bound which means we need to do as few texture samples as possible.

They typically use TBDR GPUs which means that all rendering takes place on special optimized tiles. As a side effect, reading back memory from tile to VRAM is really slow, especially on Mali devices.

This commit uses a technique where you do a small blur while downsampling, and then another small blur while upsampling to get really high quality glow. While this doesn't reduce the renderpass count very much, it does reduce the texture read bandwidth by almost 10 times. Overall glow was more texture-read bound than memory write, bound, so this was a huge win.

A side effect of this new technique is that we can gather the glow as we upsample instead of gathering the glow in the final tonemap pass. Doing so allows us to significantly reduce the cost of the tonemap pass as well.
2025-10-30 21:56:26 -07:00
Allen Pestaluky
0c7f013c55 Improve Environment color adjustments; specifically brightness and HDR 2D contrast.
This commit changes adjustments to behave as follows for all rendering configurations:

- Apply brightness to linear-encoded values, preventing contrast, saturation, and hue from being affected.
- Apply contrast to perceptually uniform (nonlinear sRGB-encoded) values, matching existing behavior when HDR 2D is disabled and producing optimal visual quality.
- Apply saturation with even color channel weights. This causes brightness of certain colors to change, but matches existing behavior when HDR 2D is disabled.

Adjustments are applied after glow and tonemapping to match existing behavior.
2025-10-23 11:08:49 -04:00
Allen Pestaluky
cafc012b05 Blend Environment glow before tonemapping and change default blend mode to screen.
Additionally, change the minimum `tonemap_white` parameter to `1.0`; users can increase `tonemap_exposure` for a similar effect to decreasing `tonemap_white` below `1.0`.

Co-authored-by: Hei <40064911+Lielay9@users.noreply.github.com>
Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
2025-10-10 12:08:08 -04:00
Stuart Carnie
90c9134875 Metal: Read gl_ViewIndex for multi-view subpasses
This is necessary to ensure the SpvCapabilityMultiView is included in
the SPIR-V, informing downstream transpilers, like Metal, that it should
enable multi-view capabilities in the generated Metal shader source.
2025-08-23 09:12:17 +10:00
Allen Pestaluky
a033656eda Fix debanding for Mobile rendering method with HDR 2D. 2025-07-24 16:11:49 -04:00
Allen Pestaluky
a1591512f8 Always perform color correction and debanding on nonlinear sRGB values.
Fixes #107730

Co-authored-by: LuoZhihao <luo_zhihao@outlook.com>
2025-07-08 13:44:53 -04:00
Dario
5a30a7e7cd Add shader baker to project exporter.
Metal Support contributed by Migeran (https://migeran.com) and Stuart Carnie.

Co-authored-by: Stuart Carnie <stuart.carnie@gmail.com>
Co-authored-by: Gergely Kis <gergely.kis@migeran.com>
2025-05-27 12:45:27 -03:00
mrjustaguy
bc746f2962 Implement FXAA 3.11 2025-04-22 22:19:06 -07:00
Allen Pestaluky
c5cf73a2e7 Optimize AgX tonemapper's handling of negative values
This change improves performance of the AgX tonemapper by allowing two matrix multiplications to be combined into one. This comes at the cost of loss of color information that could be correctly interpreted as positive RGB values in the Rec. 2020 color space. Additionally, an insignificant amount of error is intentionally introduced to the input color value to prevent the need for a second max function call before log2. The final negative color clipping has been removed to allow the tonemapper to return negative RGB values, similar to other tonemappers in Godot.
2025-01-13 17:35:35 -05:00
Allen Pestaluky
77ddaaaa91 Fix AgX sigmoid contrast curve approximation
This changes the polynomial function so that a lower input always results in a lower output and vice-versa. Additionally, the new function returns a value that is much closer to 1.0 when given an input of 1.0.
2025-01-10 18:17:38 -05:00
Hugo Locurcio
084e84be78 Add AgX tonemapper option to Environment
Technical implementation notes:

- Moved linearization step to before the outset matrix is applied and
  changed polynomial contrast curve approximation.
  - This does *not* implement Blender's chroma rotation to address hue shift.
    This hue rotation was found to have a significant performance impact.
- Improved performance by combining the AgX outset matrix with the Rec 2020 matrix.

Co-authored-by: Allen Pestaluky <allenpestaluky@gmail.com>
Co-authored-by: Clay John <claynjohn@gmail.com>
2025-01-08 17:01:16 +01:00
Rie
5efa6ba489 Fix incorrect Reinhard tonemap operator 2024-09-25 12:34:23 +02:00
Alexander Hartmann
78ede4f8b6 Fix glsl shader for Android Mali-GXXx GPUs and Vulkan API 1.3.xxx 2024-07-20 22:01:35 +02:00
Bastiaan Olij
df8ff797b7 Consistantly use USE_MULTIVIEW as the define in shaders 2024-03-11 14:40:00 +11:00
Rémi Verschelde
1163dac9e3 Merge pull request #80215 from clayjohn/HDR-2D
Add option to enable HDR rendering in 2D
2023-08-08 16:57:33 +02:00
clayjohn
57eb762bae Add option to enable HDR rendering in 2D
This is needed to allow 2D to fully make use of 3D effects (e.g. glow), and can be used to substantially improve quality of 2D rendering at the cost of performance

Additionally, the 2D rendering pipeline is done in linear space (we skip linear_to_srgb conversion in 3D tonemapping) so the entire Viewport can be kept linear.
This is necessary for proper HDR screen support in the future.
2023-08-07 11:24:03 +02:00
Matias N. Goldberg
6e7d87fb25 Use fullscreen tri instead of quad 2023-08-05 17:09:06 -03:00
Rémi Verschelde
b8870b91b5 Merge pull request #66466 from clayjohn/FXAA-fix
Take FXAA samples from half-pixel coordinates to improve quality
2022-09-27 09:58:22 +02:00
clayjohn
dbcc0fa2a6 Take FXAA samples from half-pixel coordinates to improve quality 2022-09-26 11:54:29 -07:00
clayjohn
fe69fedc1a Move deband to end of tonemapping.
This avoids artifacts when using adjustments and color correction
2022-09-23 11:46:40 -07:00
clayjohn
385ee5c70b Implement Physical Light Units as an optional setting.
This allows light sources to be specified in physical light units in addition to the regular energy multiplier. In order to avoid loss of precision at high values, brightness values are premultiplied by an exposure normalization value.

In support of Physical Light Units this PR also renames CameraEffects to CameraAttributes.
2022-08-31 12:14:46 -07:00
Hugo Locurcio
787a1e006b Fix glow in Mix mode not working correctly when FXAA is enabled
Glow must be performed after FXAA to ensure correct appearance.
2022-06-15 22:23:56 +02:00
Yuri Rubinsky
5322b171de Fix tonemapper shader to correctly apply alpha channel 2022-05-18 06:43:07 +03:00
Bastiaan Olij
9939cfc4c4 Split out bokeh_dof and copy effects 2022-05-11 11:08:56 +10:00
Bastiaan Olij
3b2267ba6d Splitting tonemapper into its own class 2022-04-28 15:00:30 +10:00