Skip to content

Conversation

@tim-blackbird
Copy link
Contributor

Objective

Add support for rendering meshes to bevy_gizmos.

Solution

Adapt the mesh rendering code from bevy_pbr and bevy_sprite for gizmo rendering.

I copied the mesh.rs files from both bevy_pbr and bevy_sprite and dumbed them down to rendering just a mesh with a color and some fake shading via a single uniform, removing support for any materials, textures or lighting, hopefully gaining some performance.

gizmo_mesh_pipeline_3d.rs is mesh.rs adapted from bevy_pbr.
gizmo_mesh_pipeline_2d.rs is mesh.rs adapted from bevy_sprite.
gizmo_mesh_shared.rs has the code that can be shared between those files.
Additional types and extraction to the render world is in mesh_pipeline/mod.rs.

The new API can be seen used in the 3d_gizmos example. (It needs some cleaning up though)

Changelog

Added mesh method to the Gizmos system parameter for drawing meshes as gizmos.
Added GizmoMeshBundle that act much like PbrBundle but instead of having a material asset it has a simple GizmoStyle component containing only an option for color at the moment.

TODO
Test whether the performance is worth the code duplication between this and bevy_pbr + bevy_sprite or whether something more janky but with less code duplication is better
Split some changes from this PR
Yeet tonemapping
Wail in terror
Test that bevy_gizmos still compiles when either bevy_pbr or bevy_sprite is disabled
Some additional cleanup, probably

@nicopap nicopap mentioned this pull request Nov 18, 2023
57 tasks
@ItsDoot ItsDoot added C-Feature A new feature, making something new possible A-Rendering Drawing game state to the screen labels Nov 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants