Add basic light gizmos#12228
Conversation
|
They're pretty, but I'm not sure I see the utility of these. Can you or @nicopap say more about where users might use these? |
The common use case I've seen them in other engines is to highlight the color and boundaries of a selected light in the editor. Unity, Unreal and Godot all have some kind of wireframe display to outline a light area and/or direction when it is selected. I'm on mobile right now but I'll update with some screenshots to show what I mean as soon as I can. Edit: Here's how it look in Godot: In Unreal: In Unity (with HDRP, as the default renderer does not seems to allow setting the spot light inner angle and the gizmo show less info). This seems to be the same approach as the one I took here. |
|
Ah neat, for debugging lights themselves. Okay, that makes much more sense to me :) |
alice-i-cecile
left a comment
There was a problem hiding this comment.
I'm happy with the code quality, and these should exist, but we need an example demonstrating how to use these :) Simple is totally fine: I basically just want a cube, a floor, some lights and the light gizmos being toggled.
crates/bevy_gizmos/src/light.rs
Outdated
| fn draw_gizmos<'a, P, S, D>( | ||
| point_lights: P, | ||
| spot_lights: S, | ||
| directional_lights: D, | ||
| gizmos: &mut Gizmos<LightGizmoConfigGroup>, | ||
| ) where |
There was a problem hiding this comment.
Nit: It might be nice from an organizational/readability perspective to split these up into a function-per-light
|
The generated |
MrGVSV
left a comment
There was a problem hiding this comment.
Just one comment. Everything else looks good to me!
Co-authored-by: Gino Valente <49806985+MrGVSV@users.noreply.github.com>
# Objective - Part of bevyengine#9400. - Add light gizmos for `SpotLight`, `PointLight` and `DirectionalLight`. ## Solution - Add a `ShowLightGizmo` and its related gizmo group and plugin, that shows a gizmo for all lights of an entities when inserted on it. Light display can also be toggled globally through the gizmo config in the same way it can already be done for `Aabb`s. - Add distinct segment setters for height and base one `Cone3dBuilder`. This allow having a properly rounded base without too much edges along the height. The doc comments explain how to ensure height and base connect when setting different values. Gizmo for the three light types without radius with the depth bias set to -1:  With Radius:  Possible future improvements: - Add a billboarded sprite with a distinct sprite for each light type. - Display the intensity of the light somehow (no idea how to represent that apart from some text). --- ## Changelog ### Added - The new `ShowLightGizmo`, part of the `LightGizmoPlugin` and configurable globally with `LightGizmoConfigGroup`, allows drawing gizmo for `PointLight`, `SpotLight` and `DirectionalLight`. The gizmos color behavior can be controlled with the `LightGizmoColor` member of `ShowLightGizmo` and `LightGizmoConfigGroup`. - The cone gizmo builder (`Cone3dBuilder`) now allows setting a differing number of segments for the base and height. --------- Co-authored-by: Gino Valente <49806985+MrGVSV@users.noreply.github.com>



Objective
SpotLight,PointLightandDirectionalLight.Solution
ShowLightGizmoand its related gizmo group and plugin, that shows a gizmo for all lights of an entities when inserted on it. Light display can also be toggled globally through the gizmo config in the same way it can already be done forAabbs.Cone3dBuilder. This allow having a properly rounded base without too much edges along the height. The doc comments explain how to ensure height and base connect when setting different values.Gizmo for the three light types without radius with the depth bias set to -1:

With Radius:

Possible future improvements:
Changelog
Added
ShowLightGizmo, part of theLightGizmoPluginand configurable globally withLightGizmoConfigGroup, allows drawing gizmo forPointLight,SpotLightandDirectionalLight. The gizmos color behavior can be controlled with theLightGizmoColormember ofShowLightGizmoandLightGizmoConfigGroup.Cone3dBuilder) now allows setting a differing number of segments for the base and height.