-
Notifications
You must be signed in to change notification settings - Fork 165
Allow shaders to be applied to UI boxes #1062
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
lovely/ui_elements.toml
Outdated
| return | ||
| elseif send then | ||
| for _, v in ipairs(send) do | ||
| local val = v.val or (v.func and v.func(self)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v.ref_table[v.ref_value] would be nice to have for consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do, this pr needs a lot more work anyways
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added, but still needs some additional debugging done
|
I attempted to get a different branch working using CanvasSprite but that ended up being too difficult for me to get working |
|
converting this to a draft again to add some changes by @lord-ruby |
|
didn't say this earlier but this should be ready to be merged |
This adds a lovely patch that allows for shaders to be applied any UI element that is drawn using
UIElement:draw_pixellated_rect().In order to apply a shader to a UI element, you must add a new config parameter,
shader, to the UI node you want to apply a shader to. This may be structured in a few ways:shader = "shader_key", which will simply use the shaderSMODS.Shaders["shader_key"]with default arguments being sent.shader = { shader = "shader_key", send = tbl}, which usesSMODS.Shaders["shader_key"], while sending arguments defined bytbl(this works the same way as the_sendargument inSprite:draw_shader())Sprite:define_draw_steps()functions. Using the string"none"or"dissolve"as the shader key will instead result in no shader being used, which is useful for layered effects.UI element shaders, by default, use a different parameter set than the typical sprite shaders, so they must be custom-made to work with this. The only arguments shared between them are
screen_scale,time(which uses a placeholder value), and the one using the shader's key. UI element shaders additionally send both the position and size of the UI element asuibox_posanduibox_size, respectively.To see an example of this in action, Entropy currently has an implementation of UI element shaders I made earlier (which I modified to create this PR), used to apply a shader to its mod badge. Arrow API also has a separate implementation to apply the Polychrome shader to UI elements.
I may come back to this to add support for text nodes and DynaText objects, but I'm already very happy with this.
Additional Info: