Thank you for this shader, it was exactly what I was looking for.
I seem to have really bad performance issues when using the fullscreen shader with the ColorRect method, especially when using "canvas_items" stretch mode, but also on "viewport".
I'm talking about having the fps of the game drop from 5000+ to 30.
Is there any way that this can be fixed? Can post more information if needed.
EDIT: Managed to improve the performance by using 1-pixel sized palettes, however, there is certainly a performance toll but it's more tolerable.
Unfortunately, optimizing the shader is very tricky, as it has to go over every pixel on the screen and check for a matching color in the provided palette.
Reducing the size of the palette is a quick solution to minimize the performance toll, that's why this shader is best suited for pixel-art and sprites with a simpler color palette.
Improving its performance significantly might be challenging, especially considering I'm quite new to shader programming. However, I'm committed to continuing my efforts to optimize it further.
If anyone has ideas on how to enhance the shader's performance, I'm open to hearing them. Any insights could lead to valuable optimizations that I may not have considered.
Thank you again for bringing this to my attention, and I'll continue to explore ways to improve the shader's performance.
This is pretty good, but the full-screen ColorRect method doesn't apply the shader to nodes that are initialized/spawned during runtime. It only applies to what was in the scene editor.
It can be applied to a single sprite2D node (if you want the effect for that node only), or it can be applied to a control node (I've tested it on a ColorRect) that covers the entire viewport to have a full screen effect.
This is an example with 2 AnimatedSpriteNode2D with the same sprite, but two different palette applied to the shader.
Did you have a different use case in mind? To provide a more tailored response, could you please share additional details about the specific use case you have in mind?
I have a spritesheet with the animations of a sprite of a football player. I want to change the color of the tshirt without having to create a new spritesheet with the new palette and I was wondering if your tool could help.
3. in the inspector assign a new shader material to the node and select the imported shader in the "shader" property.
4. in your sprite editor of choice (I use Aseprite) , create two palettes. A default palette with your default t-shirt color (you can include every color you wish to be changed), and a second palette with the same size of the default palette, and just change some of the colors. Make sure the default palette has the same colors of your character t-shirt!
5. assign the two palettes to the shader in the inspector.
6. set the tolerance to some low value (0.01)
7. now you should be able to control the effect intensity by changing the "weight" property.
You can change any of the shader properties from a script like so:
(material as ShaderMaterial).set_shader_parameter("weight", 1.0).
Hope this helps! Let me know if you need anything else.
← Return to asset pack
Comments
Log in with itch.io to leave a comment.
Thank you for this shader, it was exactly what I was looking for.
I seem to have really bad performance issues when using the fullscreen shader with the ColorRect method, especially when using "canvas_items" stretch mode, but also on "viewport".
I'm talking about having the fps of the game drop from 5000+ to 30.
Is there any way that this can be fixed? Can post more information if needed.
EDIT: Managed to improve the performance by using 1-pixel sized palettes, however, there is certainly a performance toll but it's more tolerable.
Hi, thank you for the feedback.
Unfortunately, optimizing the shader is very tricky, as it has to go over every pixel on the screen and check for a matching color in the provided palette.
Reducing the size of the palette is a quick solution to minimize the performance toll, that's why this shader is best suited for pixel-art and sprites with a simpler color palette.
Improving its performance significantly might be challenging, especially considering I'm quite new to shader programming. However, I'm committed to continuing my efforts to optimize it further.
If anyone has ideas on how to enhance the shader's performance, I'm open to hearing them. Any insights could lead to valuable optimizations that I may not have considered.
Thank you again for bringing this to my attention, and I'll continue to explore ways to improve the shader's performance.
This is pretty good, but the full-screen ColorRect method doesn't apply the shader to nodes that are initialized/spawned during runtime. It only applies to what was in the scene editor.
Hi, have you checked if the nodes spawned at runtime are ordered below the color rect in the scene?
I've done some testing and it seems to be working correctly if the color rect is rendered after all the nodes you want to apply the effect on.
this applies the color swap to the node:
this doesn't:
Just a question: when you mean a single sprite... can it be applied to the whole spritesheet or atlas?
It can be applied to a single sprite2D node (if you want the effect for that node only), or it can be applied to a control node (I've tested it on a ColorRect) that covers the entire viewport to have a full screen effect.
This is an example with 2 AnimatedSpriteNode2D with the same sprite, but two different palette applied to the shader.
Did you have a different use case in mind? To provide a more tailored response, could you please share additional details about the specific use case you have in mind?
I have a spritesheet with the animations of a sprite of a football player. I want to change the color of the tshirt without having to create a new spritesheet with the new palette and I was wondering if your tool could help.
Thanks for the interest!
So basically something like this:
You should be able to do that with these steps:
1. import the shader in your Godot project.
2. select the sprite2D node for your character.
3. in the inspector assign a new shader material to the node and select the imported shader in the "shader" property.
4. in your sprite editor of choice (I use Aseprite) , create two palettes. A default palette with your default t-shirt color (you can include every color you wish to be changed), and a second palette with the same size of the default palette, and just change some of the colors. Make sure the default palette has the same colors of your character t-shirt!
5. assign the two palettes to the shader in the inspector.
6. set the tolerance to some low value (0.01)
7. now you should be able to control the effect intensity by changing the "weight" property.
You can change any of the shader properties from a script like so:
(material as ShaderMaterial).set_shader_parameter("weight", 1.0).
Hope this helps! Let me know if you need anything else.
Thanks so much for the explanation! I will try it for sure!