Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@InvalidOS
Copy link
Contributor

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 shader SMODS.Shaders["shader_key"] with default arguments being sent.
  • shader = { shader = "shader_key", send = tbl}, which uses SMODS.Shaders["shader_key"], while sending arguments defined by tbl (this works the same way as the _send argument in Sprite:draw_shader())
  • A table of tables formatted either of the above two ways, which will result in each one being drawn in order, akin to how 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 as uibox_pos and uibox_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:

  • I didn't modify api's or I've made a PR to the wiki repo.
  • I didn't modify api's or I've updated lsp definitions.
  • I didn't make new lovely files or all new lovely files have appropriate priority.

return
elseif send then
for _, v in ipairs(send) do
local val = v.val or (v.func and v.func(self))
Copy link
Collaborator

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

Copy link
Contributor Author

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

Copy link
Contributor Author

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

@InvalidOS InvalidOS marked this pull request as draft November 2, 2025 23:13
@InvalidOS InvalidOS marked this pull request as ready for review November 5, 2025 15:55
@InvalidOS
Copy link
Contributor Author

I attempted to get a different branch working using CanvasSprite but that ended up being too difficult for me to get working

@InvalidOS InvalidOS marked this pull request as draft November 7, 2025 14:08
@InvalidOS
Copy link
Contributor Author

converting this to a draft again to add some changes by @lord-ruby

@InvalidOS InvalidOS marked this pull request as ready for review November 7, 2025 16:04
@InvalidOS
Copy link
Contributor Author

didn't say this earlier but this should be ready to be merged

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.

2 participants