-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Add basic light gizmos #12228
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 :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: It might be nice from an organizational/readability perspective to split these up into a function-per-light
Co-authored-by: Gino Valente <[email protected]>
The generated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one comment. Everything else looks good to me!
Co-authored-by: Gino Valente <[email protected]>
# 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 <[email protected]>
Objective
SpotLight
,PointLight
andDirectionalLight
.Solution
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 forAabb
s.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 theLightGizmoPlugin
and configurable globally withLightGizmoConfigGroup
, allows drawing gizmo forPointLight
,SpotLight
andDirectionalLight
. The gizmos color behavior can be controlled with theLightGizmoColor
member ofShowLightGizmo
andLightGizmoConfigGroup
.Cone3dBuilder
) now allows setting a differing number of segments for the base and height.