Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Volumetric Fog VoxelGI updates #86023

Merged
merged 1 commit into from Mar 1, 2024

Conversation

bitsawer
Copy link
Member

The problem was that when VoxelGI volumes became visible in the camera or leave it, the active VoxelGI culling results were not updated to volumetric fog uniform sets. The updates only happened when toggling the enviroment off and on or resizing the windows, which forces a full update. More specifically, this volumetric fog uniform update code needs to be re-run every time when VoxelGI culling results change:

RD::Uniform u;
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
u.binding = 12;
for (int i = 0; i < RendererRD::GI::MAX_VOXEL_GI_INSTANCES; i++) {
u.append_id(p_settings.rbgi->voxel_gi_textures[i]);
}
uniforms.push_back(u);
copy_uniforms.push_back(u);

There are few similar volumetric fog update issues that I think might be caused by similar missing uniform (or some other) update, for example #83990 (the same workaround also works there, turning environment off and on or resizing the window).

The Volumetric Fog and VoxelGI interactions and uniform set handling received some work in #76437, #76550 and #77703, so it could be useful to get some feedback from @RandomShaper here. There might be a more elegant or efficient way to implement the update notifying logic, especially if there are other cases like #83990 that need to be also handled in the future, but this should fix the immediate problem.

@bitsawer bitsawer added this to the 4.3 milestone Dec 11, 2023
@bitsawer bitsawer requested a review from a team as a code owner December 11, 2023 09:13
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, it works as expected. I've also tested a larger scene with a single VoxelGI node and it still renders correctly.

Before

simplescreenrecorder-2023-12-11_11.40.20.mp4

After (this PR)

simplescreenrecorder-2023-12-11_11.45.19.mp4

@akien-mga akien-mga added the cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release label Dec 11, 2023
Copy link
Contributor

@BastiaanOlij BastiaanOlij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The heart of the fix seems correct, right now we detect whether the uniform is null or dependencies have been updated, but then only create the uniform set if it's null.
I'm guessing at some point in time we would have freed the uniform set maybe?
But freeing the uniform set before (re)creating it makes sense.

Setting dependencies as changed while we update those seems sound to me as well.

@akien-mga
Copy link
Member

akien-mga commented Feb 28, 2024

@bitsawer Could you rebase this PR just to make sure it still passes CI a few months later?

Edit: Done myself.

@akien-mga akien-mga merged commit 7470020 into godotengine:master Mar 1, 2024
15 checks passed
@akien-mga
Copy link
Member

Thanks!

@akien-mga
Copy link
Member

Cherry-picked for 4.2.2.

@akien-mga akien-mga removed the cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release label Mar 11, 2024
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.

Volumetric fog with VoxelGI weird behavior depending on camera position
4 participants