Feature Discussion: iMouse Uniforms for Custom Shaders #9452
Unanswered
brad-alexander
asked this question in
Feature Requests, Ideas
Replies: 2 comments
This comment was marked as spam.
This comment was marked as spam.
-
|
One thing to note is that |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Feature Discussion: iMouse Uniforms for Custom Shaders
Summary
I've implemented support for passing mouse position to custom shaders via the
iMouseuniform (currently documented as "NOT CURRENTLY SUPPORTED" in the config).Implementation Details
The implementation adds real-time mouse cursor tracking that passes surface pixel coordinates to custom shaders through the existing uniform system:
renderer.State.Mouseto track raw surface coordinatesSurface.cursorPosCallbackandmouseRefreshLinksto populate surface coordinatesRenderer.updateCustomShaderUniformsto convert surface coords to framebuffer pixels with proper Y-axis flipping for Metal/OpenGLThe mouse data flows from surface events → render state → framebuffer conversion → uniform buffer, providing
vec4 iMouseas(x, y, 0, 0)in surface pixels.Implementation Concerns
Though I'm an experienced software dev, as a Zig novice I have some concerns about this implementation:
mouseRefreshLinksnear other mouse handling related to rendering - this may not be the ideal locationFiles Modified
src/renderer/generic.zigsrc/renderer/State.zigsrc/Surface.zigsrc/config/Config.zig-- comments onlyTesting
zig build)20251027-0517-53.8232374-2.mp4
Questions for Maintainers
mouseRefreshLinks?Branch: main...brad-alexander:ghostty:ba/iMouse
AI Assistance Disclosure: This implementation was created with assistance of Codex/Amp with heavy supervision by a Zig novice 😄
Beta Was this translation helpful? Give feedback.
All reactions