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

Vulkan Clustered: Cull direction flips as camera moves with multiple MeshInstance3Ds using the same mesh at negative and positive scales #58546

Closed
jtnicholl opened this issue Feb 26, 2022 · 1 comment · Fixed by #67176

Comments

@jtnicholl
Copy link
Contributor

Godot version

v4.0.alpha.custom_build [0393057]

System information

Linux (KDE Neon 5.24) w/ kisak-mesa ppa, Radeon R9 390x, amdgpu driver

Issue description

When multiple MeshInstance3D nodes are in the scene using the same Mesh resource, and some but not all of the nodes have a negative scale, the nodes at one scale have their cull direction flipped. Moving the camera so that the nodes go in or out of view causes the directions to flip. Continuing to move the camera causes the nodes to repeatedly flip back and forth.

2022-02-25_19-46-22.mp4

If all nodes using the same mesh are at a negative scale, they render normally, with negative scale only mirroring the object without affecting its cull direction. The issue also does not occur on the mobile backend, only clustered.

Steps to reproduce

Create a MeshInstance3D node in the scene and add a mesh. Duplicate it a few times and scatter them around. Set the scale to -1 on an axis for half of them. Half of them will have their cull direction flipped. Move the camera around so they go in and out of view and the cull directions flip back and forth.

Minimal reproduction project

ScaleIssue.zip
Same scene from the video.

@Calinou Calinou added this to the 4.0 milestone Feb 26, 2022
@Calinou Calinou changed the title Cull direction flips as camera moves with multiple MeshInstance3Ds using the same mesh at negative and positive scales Vulkan Clustered: Cull direction flips as camera moves with multiple MeshInstance3Ds using the same mesh at negative and positive scales Feb 26, 2022
@cooperra
Copy link
Contributor

I can confirm that this still happens on 4.0.alpha7.

akien-mga pushed a commit that referenced this issue Oct 11, 2022
Negatively scaled objects should be mirrored. This is already implemented, but it breaks when mirrored and non-mirrored instances of the same object are visible together.

It turns out that the code that skips-over repeats in `RenderForwardClustered::_render_list_template` also skips the code that accounts for the culling mode of mirrored objects.

The solution here is to consider the `mirror` flag when determining repeats. This might result in more draw commands than necessary since a mirrored object can split a group of non-mirrored instances in two.

This problem doesn't appear in the mobile renderer because the repeat optimization isn't implemented there yet.

The problem still appears in MultiMeshInstance3D in *all* renderers.

Fixes #62879 and #58546.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants