#How to render gizmos in a 3d camera's screen space?

6 messages · Page 1 of 1 (latest)

heavy flame
#

I want to use gizmos to visualize debug information on-screen at all times, but even using the 2d gizmos renders them at 0,0 world space instead of 0,0 screen space

modest marlin
#

which gizmos are you using

pearl gazelle
# heavy flame I want to use gizmos to visualize debug information on-screen at all times, but ...

gizmos are always world space.

to work around this, render them to a separate render layer by setting it with https://docs.rs/bevy/latest/bevy/prelude/struct.GizmoConfig.html

and then use a extra 2d camera set to thay render layer as well which should allow you to have them on top of everything else. the default 2d camera setup should mean 1 unit world space = 1 pixel screen space, with the origin in the middle (unlike most things where the origin is top-left)

heavy flame
#

ooooh ok thank you!

modest marlin
#

oh that's a good workaround
i was going to recommend passing the camera's GlobalTransform (plus clip offset) to the gizmo draw call

paper ore
#

Tbh my first instinct would be to apply the cameras transform to the position you want to render them, then the position is camera relative