bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Gizmos Billboards

Open lynn-lumen opened this issue 1 year ago • 8 comments

Objective

  • Most game engines like Unity and Unreal Engine have the ability to draw sprites as gizmos. This may be useful for drawing "nodes" for paths, lights and much more.
  • This PR adds flat coloured billboards for bevy. Since this PR already is pretty big, I would like to add drawing textures on the billboards in a future PR.

Solution

  • Moved the rendering code of line gizmos into its own module.
  • Added rendering code for billboard gizmos.
  • Added gizmos.billboard(position_3d, color) and gizmos.billboard_2d(position_2d, color) to actually draw gizmos.
  • GizmoConfignow includes two additional properties:
    • .billboard_size to configure the visual size (length along the edge) of billboards. This behaves very similar to .line_width
    • .billboard_perspectiveto apply perspective scaling to billboards.
  • The GizmoConfig.depth_bias applies to billboards aswell.

Showcase

You can draw billboards like this:

gizmos.billboard(Vec3::ZERO, RED);

Which produces results like these...

in 3D:

https://github.com/user-attachments/assets/6643d993-76d4-4acb-99f9-bd4a8b01c0d3

and in 2D:

Screenshot 2024-08-31 at 18 24 46

lynn-lumen avatar Aug 31 '24 17:08 lynn-lumen

Very nice: thanks for the polished video!

alice-i-cecile avatar Aug 31 '24 18:08 alice-i-cecile

@lynn-lumen what needs to be done here to take this out of draft?

alice-i-cecile avatar Sep 03 '24 14:09 alice-i-cecile

I don' really understand the ambiguity error🥲 Any help would be much appreciated:)

lynn-lumen avatar Sep 03 '24 14:09 lynn-lumen

It looks like you've added some ambiguous systems. The diff of "what new systems are conflicting" is frustratingly annoying to get at though: I'm going to be spending some time today driving the count down to zero, which should make this much clearer.

alice-i-cecile avatar Sep 03 '24 14:09 alice-i-cecile

#15031 should solve your pain here: particularly https://github.com/bevyengine/bevy/pull/15031/commits/5b157e98ac4728074ab0fe24282db973c70aa5b3

alice-i-cecile avatar Sep 03 '24 16:09 alice-i-cecile

Thanks, I will have another try tomorrow :)

lynn-lumen avatar Sep 03 '24 22:09 lynn-lumen

#15031 should solve your pain here: particularly 5b157e9

Thanks again, that really was very helpful :D

lynn-lumen avatar Sep 04 '24 20:09 lynn-lumen

@alice-i-cecile This is ready for review now :)

lynn-lumen avatar Sep 09 '24 18:09 lynn-lumen

@lynn-lumen @tychedelia what is required to move this PR forward?

TimJentzsch avatar May 17 '25 08:05 TimJentzsch

@lynn-lumen @tychedelia what is required to move this PR forward?

This PR probably needs updating to the current version. Apart from that, I am not aware of anything blocking this PR. I believe @tychedelia requested format changes to some of the shader code though, but I was unable to determine what exactly they meant.

lynn-lumen avatar May 17 '25 18:05 lynn-lumen

@lynn-lumen @tychedelia what is required to move this PR forward?

This PR probably needs updating to the current version. Apart from that, I am not aware of anything blocking this PR. I believe @tychedelia requested format changes to some of the shader code though, but I was unable to determine what exactly they meant.

Line 43 and 76-79 aren't formatted. The conflicts might be complex to resolve. We've moved towards retaining gizmos which may be worth evaluating if you want to revive this.

tychedelia avatar May 17 '25 19:05 tychedelia

Ahh OK, thank you for clarifying :) If there still is interest, I will take a look at updating this next week.

lynn-lumen avatar May 17 '25 19:05 lynn-lumen