A downloadable asset pack

Buy Now$2.00 USD or more

A Godot shader that allows you to quickly swap color palette for a single sprite or for the entire screen.


It's intended for pixel art games but could work with other art styles.

Easy to use, you can add it to any sprite node or you can apply it to a control node (ColorRect) that covers the entire viewport to affect the entire scene.


The shader works with 2 Lut textures, a reference palette and a swap palette. It will swap all the reference color to their respective colors in the swap palette texture.

There is a "weight" parameter you can tweak to set the amount of blend you desire.


There is also a "tolerance" parameter that affects how closely the colors should match, you can set it to a very small number for exact match.

Toggle the "Is Full Screen" parameter on for full-screen effects.  => From version 3.0 there are now two separate files for single node and full screen effects to optimize performance.


NOTE: to make it work you'll need to provide the two palette textures to the shader and make sure you use those palettes in your sprites


Tested in Godot 4.1.

Thanks to Kenney for the tileset in the screenshots.

By purchasing, you agree that you may not resell or redistribute the source code in any way (ex: GitHub and Marketplace). The product can be used commercially in any game or software.

StatusReleased
CategoryAssets
Rating
Rated 5.0 out of 5 stars
(1 total ratings)
Authorsglmnaz
Made withGodot
TagsColorful, Godot, Pixel Art, Shaders

Purchase

Buy Now$2.00 USD or more

In order to download this asset pack you must purchase it at or above the minimum price of $2 USD. You will get access to the following files:

Shader v3.0 3 kB
Shader v2.0 1 kB

Development log

Comments

Log in with itch.io to leave a comment.

(1 edit) (+1)

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.

(1 edit) (+2)

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.

(1 edit)

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:

(+1)

Just a question: when you mean a single sprite... can it be applied to the whole spritesheet or atlas?

(1 edit)

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!

(2 edits)

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!