Skip to content

Add High Quality Once update mode to Sky#55933

Open
Calinou wants to merge 1 commit into
godotengine:masterfrom
Calinou:sky-add-once-update-mode
Open

Add High Quality Once update mode to Sky#55933
Calinou wants to merge 1 commit into
godotengine:masterfrom
Calinou:sky-add-once-update-mode

Conversation

@Calinou
Copy link
Copy Markdown
Member

@Calinou Calinou commented Dec 14, 2021

Related to #55929.

This allows for generating high-quality reflections once when the sky resource is first assigned (or when the project starts).

The use case is to use sky shaders that feature real-time clouds and the like without impacting performance nearly as much, since the radiance map is no longer constantly regenereated during gameplay. When using this mode, clouds won't move in reflections anymore, but this is hardly a problem in most scenes since clouds are hard to see moving in reflections.

Additionally, with some shader trickery (e.g. toggling a boolean uniform after loading the scene), this allows you to have a radiance map that looks nothing like the sky if you wish 😉
While not physically accurate, this has been requested many times over the years: godotengine/godot-proposals#3593

Testing project: test_sky_update_once.zip
Press C to cycle between sky update modes (including Automatic).

This PR can likely be remade for 3.x if desired.

This closes #53969 (at the cost of incorrect reflections, but not much can be done about this, other than adjusting ambient light intensity at run-time).

Performance

OS: Fedora 34
CPU: Intel Core i7-6700K
GPU: GeForce GTX 1080

Update mode FPS
High Quality Once 657 FPS (1.52 mspf)
High Quality 23 FPS (43.48 mspf)
High Quality Incremental 151 FPS (6.62 mspf)
Real Time 321 FPS (3.12 mspf)

@Calinou Calinou requested review from a team as code owners December 14, 2021 15:34
@Calinou Calinou added this to the 4.0 milestone Dec 14, 2021
@Calinou Calinou force-pushed the sky-add-once-update-mode branch 4 times, most recently from 7f8e358 to 27028e8 Compare December 14, 2021 15:51
This allows for generating high-quality reflections once when the
sky resource is first assigned (or when the project starts).

The use case is to use sky shaders that feature real-time clouds and
the like without impacting performance nearly as much, since the radiance
map is no longer constantly regenereated during gameplay.
@Calinou Calinou force-pushed the sky-add-once-update-mode branch from 27028e8 to 9ba1932 Compare December 14, 2021 15:52
@Zireael07
Copy link
Copy Markdown
Contributor

Yay!

(Personally I'm halfway through moving my racer project to Vulkan, but a 3.x backport would be awesome if possible)

@clayjohn
Copy link
Copy Markdown
Member

I don't think that this resolves godotengine/godot-proposals#3593

Wouldn't it be preferable to implement godotengine/godot-proposals#3593 e.g. provide a different sky source for reflections and background?

To me, the current workflow in this PR seems a little hacky. Users would have to write a script to change the sky_material after one frame if they want to separate reflections from the sky background. Otherwise, they would just end up with whatever their lighting/material setup was on frame 0.

@mrjustaguy
Copy link
Copy Markdown
Contributor

It sort of resolves #3593, as setting the Sky for radiance map to update only once does allow for a Static Sky to Provide Ambient and Reflected Lighting, while also allowing the Sky itself to be changed, without affecting the radiance maps..

I mean this doesn't resolve it the way it's proposed, but it does add a workaround that gives a desired result and it is still unclear how much demand there is for something like that for it to be made more user-friendly way of doing it.

@Calinou
Copy link
Copy Markdown
Member Author

Calinou commented Dec 14, 2021

I don't think that this resolves godotengine/godot-proposals#3593

It's tangentially related, but this is indeed a separate problem. I don't think this PR resolves godotengine/godot-proposals#3593, but it does provide another way to work around the original issue.
On the other hand, you can already work around this by placing a ReflectionProbe within an unshaded sphere that has a panorama sky texture assigned to it 🙂
So I'm not sure this PR actually provides a better way to achieve different reflections.

However, this PR does provide a way to resolve notable performance issues that occur when performing sky updates that do not change the radiance map in a significant way. This is why I feel it's important to address this before 4.0 is released.

@clayjohn
Copy link
Copy Markdown
Member

notable performance issues that occur when performing sky updates that do not change the radiance map in a significant way

Is this an issue that users have been reporting? I'm concerned that we may be chasing an invented use-case and not an actual problem that users are running into. I'm happy to be shown I am wrong here, but I haven't seen any users who are slightly tweaking their sky every frame and running into resulting performance issues. Although, personally, I really like the idea of being able to set the reflections to not update, and then being able to update them when you choose. But I feel that I am being too speculative.

I have a feeling that if users want to have a static sky for reflections along with a dynamic sky for the background, the best option is the one presented in godotengine/godot-proposals#3593,

@clayjohn
Copy link
Copy Markdown
Member

clayjohn commented Feb 10, 2022

We discussed this PR during today's PR review meeting. The consensus is that we should add a project setting to control how often the radiance map is updated (either once, spread over N frames, or updated every frame). In order to do that we will need to re-evaluate the rendering probe update options and the Update Mode settings in Sky (high quality incremental may no longer be needed).

edit: To be clear, we need to go through the proposal process to figure out something that will work and be intuitive. Upon further reflection, having the update time as project setting may not make sense as the realtime update mode is made to operate in a single frame and won't have the same benefits for calculating over multiple frames that the high quality mode has.

@akien-mga
Copy link
Copy Markdown
Member

Is this still useful after #58177?

@Calinou
Copy link
Copy Markdown
Member Author

Calinou commented Feb 18, 2022

Is this still useful after #58177?

Yes, but this PR needs to be redesigned to follow clayjohn's comment above. On slow integrated graphics, freezing radiance map updates entirely can make the difference between an unplayable game and a playable game 🙂

Alternatively, it's possible to decrease the radiance map size and GGX steps to the minimum value, but this will make reflections look worse (even in scenes with a static sky).

@clayjohn
Copy link
Copy Markdown
Member

clayjohn commented Feb 18, 2022

To add to Calinou's comment, something like this is still needed because for complex sky shaders, the slowest part is the sky shader rather than the generation of the radiance map. #58177 made generating a high quality radiance map much cheaper, but it does nothing for expensive shaders.

@Calinou I am thinking that we do the following:

  1. Change the name of "Update Mode" to "Filter Mode" and keep the current options
  2. Add an "update mode" that controls how often the sky shader is run (but does not impact the radiance map filtering) with the following options
UPDATE_MODE_ALWAYS; // all 6 faces every frame
UPDATE_MODE_ONCE; // All six faces for one frame then freeze update
UPDATE_MODE_INCREMENTAL; // Update over 6 frames
UPDATE_MODE_INCREMENTAL_ONCE; // Update over 6 frames then freeze update

The radiance update would only start after the cubemap is updated after running the sky shader.

@YuriSizov YuriSizov modified the milestones: 4.0, 4.1 Feb 9, 2023
@clayjohn clayjohn modified the milestones: 4.1, 4.x May 23, 2023
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.

Huge performance drop when a directional light is rotating (due to radiance map regeneration)

6 participants