Skip to content

Conversation

@Vipitis
Copy link
Collaborator

@Vipitis Vipitis commented May 5, 2025

Very WIP, so the branch is messy. Mentioned in #8

I threw this together at the airport just now after thinking about it for the past week.

Currently works with the example provided but theoretically should work with all single pass shaders.
Only float and int dtypes and only glsl just now. Also missing common code.

Based on the imgui example in wgpu, but I can already think of a bunch of ways to make it fit better with the existing structures.

most likely todos:

  • better example, perhaps this: https://www.shadertoy.com/view/Wf3SWn (needs to loop in L73)
  • can we somehow access the preprocessor from naga (or via tree-sitter?)
  • add a dataclass to hold all the information
  • support common and buffer passes like buffer_a.value
  • can imgui be it's own renderpass (instead of attaching to the image?)
  • Sliders should have an option to reset to default
  • Print the value off all constants upon exit (on_close event?)
  • skip common constants (pi, tau, eps?, ...)
  • vec3 dtype for color picker and directions!?
  • can we get const float name 1.23 too?
  • a bunch of tests
  • should this be an optional dependency
  • does imgui-bundle work with python3.9 or do we need to drop it?
  • WGSL has no #define - do we support any patterns there?
  • cleanup

@Vipitis Vipitis mentioned this pull request May 5, 2025
11 tasks
@Vipitis
Copy link
Collaborator Author

Vipitis commented May 20, 2025

little demo video to show the poc working from cli:

imgui_demo.mp4

@Korijn
Copy link
Contributor

Korijn commented Jun 8, 2025

This is super cool!

@ShnitzelKiller
Copy link

I get the error AttributeError: 'imgui_bundle._imgui_bundle.imgui.ImFontAtlas' object has no attribute 'get_tex_data_as_rgba32' when I try to launch a shader with the --imgui argument. On macOSX.

@Vipitis
Copy link
Collaborator Author

Vipitis commented Aug 26, 2025

Hey @ShnitzelKiller can you try out the wgpu main brach? The latest release is missing some fixes for the most recent imgui-bundle release see pygfx/wgpu-py#725

Otherwise downgrading imgui-bundle might do it.

@ShnitzelKiller
Copy link

Installing main branch of wgpu fixed it.

Comment on lines +191 to +192
front_view = rp.texture_front.create_view()
front_ref = rp.main._imgui_backend.register_texture(front_view)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, came cross here from pygfx/wgpu-py#729 (comment).
It’s generally better not to create and register new texture views every frame in the render loop. Instead, a global texture view should be registered and used during initialization, or a imgui.TextureRef can be registered and created only at the first time the GUI is rendered.
If it’s absolutely necessary to create and register new texture views each frame in the render loop, you must manually call the newly added unregister method in pygfx/wgpu-py#749 to release the old texture view resources.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cheers for the heads up,
the render target for the buffer passes is switching back and forth between two textures(maybe I should also keep both views...) so I will likely have to register both of them during initialization and figure out a way to select the correct one in the gui function or swap them around after the draw function too. Sorta is a little against the "intermediate mode" concept.

I will have a think since this whole branch needs a better pattern anyway, why too many if self._imgui

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants