Cursor uniforms for custom shaders #6901
-
Hi, After reading issue #4199, I thought this feature could be implemented using custom shaders if Ghostty passes some additional uniforms. This would not only enable the requested functionality but also allow for more interactive and dynamic shader effects. I have never worked with Zig before, so my implementation might not be ideal, but I hope it serves as inspiration. My changes should maintain compatibility with ShaderToy, as they only introduce new uniforms without altering existing behavior. Currently, I have implemented these changes for OpenGL. Below are two example shaders demonstrating what’s possible with this approach: blaze_trail.mp4simple_trail.mp4You can find the changes here: https://github.com/KroneCorylus/ghostty/tree/custom-shaders-cursor-uniforms I’d love to hear your thoughts on this approach. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 25 replies
-
May be worth posting in the #development channel on discord that you are looking for feedback! |
Beta Was this translation helpful? Give feedback.
-
Hey that looks super cool! The diff looks clean as well (with some minor changes needed). Would you be interested in opening a PR? |
Beta Was this translation helpful? Give feedback.
-
I like this! Super clean diff. I think exposing cursor times to a custom shader is a no-brainer. I'll review your PR and port it to Metal and there's no need to block that. Separately, you've nerd sniped me so I think I may add generalized cursor trail support to the core of Ghostty. I didn't realize it could be this simple, really. By doing it in core we can be slightly more power efficient because we can avoid frame redraws if we know the cursor hasn't moved over a certain period of time. For custom shaders, we redraw on every frame (vsync) because we can't know if animations exist or not (there's a config to disable this but then custom shaders are only drawn on terminal state change, and only one frame). Do you have the shaders that you used to make these animations, and would you be open to them being contributed? |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm super interested in your stuff, so I cloned your pr branch and compiled it myself. While there were no issue loading the shader, it seems like it's not actually showing anything on my computer. Is that a MacOS issue? |
Beta Was this translation helpful? Give feedback.
-
Implemented in #7648. Thank you! |
Beta Was this translation helpful? Give feedback.
-
@qwerasd205 Thanks for all the hard work. Much appreciated. That said, I had a question to ask please - How can I add the custom shader for those cursor effects? I have already downloaded the shaders from @KroneCorylus's repo and updated my config to use those shaders, but its not working for me. I have also updated Ghostty to the latest version which was released today. Also I dont know any Zig. Kindly help. Thanks |
Beta Was this translation helpful? Give feedback.
Implemented in #7648. Thank you!