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

Make the occlusion culling debug draw mode draw a translucent overlay #79733

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Jul 21, 2023

This allows for easy, depth-aware navigation in the 3D editor while being able to view which meshes are occluders and which meshes aren't.

I've tested this change with both Forward+ and Mobile rendering methods. No Vulkan validation errors are reported when running with --gpu-validation on either rendering method. (The Compatibility rendering method currently doesn't support most debug draw modes, including the occlusion culling buffer. Occlusion culling itself does work though.)

Thanks @myaaaaaaaaa for the help 🙂

Testing project: test_occlusion_culling_buffer.zip

Preview

The two cubes in the front have occluders, while the cube in the back doesn't.

image

@Calinou Calinou added this to the 4.x milestone Jul 21, 2023
@Calinou Calinou requested a review from a team as a code owner July 21, 2023 01:09
@Calinou Calinou force-pushed the occlusion-culling-debug-draw-translucency branch from 34195cf to 63a59c9 Compare July 21, 2023 01:10
@BlueCube3310
Copy link
Contributor

I think this is a useful change, especially since the jittered buffer makes it very difficult to see the shapes of the objects. Needs a rebase though

@Calinou
Copy link
Member Author

Calinou commented Nov 19, 2024

Rebased and tested again, it works as expected.

The "vignette" effect is also gone (it was already fixed in master). I've updated the screenshot in OP accordingly.

@Calinou Calinou force-pushed the occlusion-culling-debug-draw-translucency branch from 63a59c9 to 2823936 Compare November 19, 2024 22:29
Copy link
Contributor

@BlueCube3310 BlueCube3310 left a comment

Choose a reason for hiding this comment

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

Looks good to me, I tested it on several scenes with many meshes and it works correctly. Additionally it makes it easier to notice how the occluders interact with the scene

@akien-mga akien-mga requested a review from clayjohn November 29, 2024 16:34
@@ -203,6 +203,14 @@ void main() {
color.rgb = normalize(color.rgb * 2.0 - 1.0) * 0.5 + 0.5;
}

#ifdef MODE_OCCLUSION_CULLING_BUFFER
Copy link
Member

Choose a reason for hiding this comment

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

This should just be a flag otherwise we are increasing load times for no reason

Copy link
Member Author

@Calinou Calinou Nov 29, 2024

Choose a reason for hiding this comment

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

I've pushed a second commit to attempt this, but it doesn't seem to work on my end (it just renders as it did before).

@Calinou Calinou force-pushed the occlusion-culling-debug-draw-translucency branch 2 times, most recently from ff35f6e to 34f10ed Compare November 29, 2024 23:14
@@ -568,6 +586,10 @@ void CopyEffects::copy_to_fb_rect(RID p_source_rd_texture, RID p_dest_framebuffe
copy_to_fb.push_constant.flags |= COPY_TO_FB_FLAG_NORMAL;
}

if (p_occlusion_culling_buffer) {
copy.push_constant.flags |= COPY_TO_FB_FLAG_OCCLUSION_CULLING_BUFFER;
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably be

Suggested change
copy.push_constant.flags |= COPY_TO_FB_FLAG_OCCLUSION_CULLING_BUFFER;
copy_to_fb.push_constant.flags |= COPY_TO_FB_FLAG_OCCLUSION_CULLING_BUFFER;

Copy link
Member Author

@Calinou Calinou Dec 4, 2024

Choose a reason for hiding this comment

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

Thanks 🙂 I've tried this but now I just see a fully opaque red viewport when the debug draw mode is enabled. So there's still an issue somewhere else.

Copy link
Contributor

Choose a reason for hiding this comment

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

The correct pipeline is never applied since it relies on the "COPY_TO_FB_OCCLUSION_CULLING_BUFFER" mode that doesn't get used now

Calinou and others added 2 commits December 4, 2024 20:03
This allows for easy, depth-aware navigation in the 3D editor while
being able to view which meshes are occluders and which meshes aren't.

Co-authored-by: myaaaaaaaaa <[email protected]>
@Calinou Calinou force-pushed the occlusion-culling-debug-draw-translucency branch from 34f10ed to 06efb5b Compare December 4, 2024 20:13
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.

Make the occlusion culling debug draw mode display a translucent overlay instead of replacing the viewport
3 participants