Skip to content

Fix performance regression when rendering collision shapes#108530

Merged
Repiteo merged 1 commit into
godotengine:masterfrom
mihe:physics-debug-perf
Jul 15, 2025
Merged

Fix performance regression when rendering collision shapes#108530
Repiteo merged 1 commit into
godotengine:masterfrom
mihe:physics-debug-perf

Conversation

@mihe
Copy link
Copy Markdown
Contributor

@mihe mihe commented Jul 11, 2025

Fixes #105248.
Relates to #90644.

This takes the average frame time of the MRP in #105248 down from 12.7 ms to 6.0 ms on my machine, which I would argue is close enough to the 5.0 ms in 4.3-stable to consider this issue largely resolved. It's unclear where the rest of the regression comes from.

This is done by simply going back to using the shared SceneTree::collision_material, as was done prior to #90644, instead of creating a new material for every Shape3D instance, presumably allowing the renderer to batch the draw calls or something.

GridMap was the only thing currently still relying on the old SceneTree::collision_material, so I changed it to provide vertex colors, like Shape3D does, instead of relying on SceneTree::collision_material to have an albedo color set, the value of which it gets from the debug/shapes/collision/shape_color setting.

Shape3D::get_debug_mesh was also duplicating the vertex array for no good reason, so I fixed that as well.

@smix8
Copy link
Copy Markdown
Contributor

smix8 commented Jul 15, 2025

This fixes more or less the immediate issue that users can't performance-open their larger scenes due to the overdetailed new debug that was added and not really tested at scale (... how often do we have to teach this lesson ...).

Tbh that entire new and old physics debug is made so wonky both in performance and settings but a larger changes requires more time so good enough for now.

@Repiteo Repiteo merged commit e1e2277 into godotengine:master Jul 15, 2025
20 checks passed
@Repiteo
Copy link
Copy Markdown
Contributor

Repiteo commented Jul 15, 2025

Thanks!

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.

"Visible Collision Shapes" debug option has an important performance regression since Godot 4.4

3 participants