pkdawson / imgui-godot

Dear ImGui plugin for Godot 4
MIT License
318 stars 18 forks source link

Input latency #30

Closed 107zxz closed 1 year ago

107zxz commented 1 year ago

imgui-godot seems to have ~2x more input latency than SDL2 and GLFW implementations of imgui, despite running at the same framerates (see below videos).

SDL2 https://user-images.githubusercontent.com/55370376/222351571-13dc9c90-aeb3-41e9-ac63-f17b1a8a6e1a.mov

Godot https://user-images.githubusercontent.com/55370376/222351846-0112cd5f-5f31-4225-8349-755dc7f460b1.mov

pkdawson commented 1 year ago

For the most part, I think I'm doing the best I can with what Godot gives me. For each frame, input events are processed, and then the ImGui frame is rendered and displayed, there's no additional latency there.

That lag looks much worse than anything I can reproduce at 60fps on Windows, but I'll check it out on macOS later. There is one thing I can do to slightly improve hardware cursor tracking.

pkdawson commented 1 year ago

If you create a new project without imgui-godot and add an embedded subwindow (the Window node), you should notice that it lags behind the cursor in a very similar way at 60fps. So I think this is just an issue with how Godot's macOS rendering works, which is beyond my expertise.

My idea for directly sampling the cursor position didn't make a noticeable difference. I'll probably implement it anyway, because it is at least theoretically better.

pkdawson commented 1 year ago

v3.5.9 implements the change I mentioned, which in my testing can tighten up the mouse position by a pixel or two, but it's not really a noticeable improvement. I don't think there's anything more I can do.

107zxz commented 1 year ago

The issue definitely seems to be on Godot's side. Thanks for looking into it