Skip to content

Eye Dropper is a shader for Godot (using gdshader language) that allows performing color palette swapping in an intuitive way.

License

Notifications You must be signed in to change notification settings

nadjiel/eye-dropper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎨 Eye Dropper

Banner

Godot v4.3+ License Latest Release

Eye Dropper is a shader for the Godot engine (GDShader) that helps with quick color palette swapping easily customizable through shader parameters.

This shader is a canvas_item type of shader that was meant, at least initially, to be used with CanvasItems nodes in Godot. Contributions are welcome to make a version that works with 3D nodes.

With this shader, you can configure your palettes through Textures or through PackedColorArrays, or even use both options, if it's more convenient to you.

✨ Features

🖌️ Palette Swapping

The main purpose of this project is allowing easy color swapping for CanvasItems nodes in the Godot engine. That's achieved with the eye_dropper.gdshader script, which exposes handy properties that can be tweaked programatically, or manually in the Godot editor, in order to achieve different palettes dynamically.

Color swapping illustration
Illustration of the color swapping process

For that palette swapping to happen, two important pair of properties are available in the shader parameters: the input_palette_array and output_palette_array and the input_palette_texture and output_palette_texture.

Both of these pair of properties serve the same functionality: allowing you to define what colors should be replaced by what colors in the color swapping process.

Shader parameters screenshot
Screenshot of the shader parameters

The difference between the Array based and the Texture based properties is that the Texture ones are easier if you want to swap quickly from a pre-stablished palette saved in a Texture to another one.

The Array based, on the other hand makes it easier to swap between palettes that aren't predefined in a texture. That's useful when you wanna make dynamic color swapping that changes frequently, or even smooth animated color swapping with the use of Tweens or AnimationPlayers.

There's a catch with the Array parameters, though. To be able to use the palette Arrays with various colors, make sure to tweak the max_palette_array_size constant in the eye_dropper.gdshader file so that it attends your project's needs.

By default, that constant is set to 4, which means that only 4 colors are allowed at maximum using the Arrays, but, as mentioned, that's easily tweakable.

This is implemented that way because in GDShaders Arrays must have a constant initial size predefined, which I decided to let as 4, initially.

👓 Transparency support

It's important to note that both the Texture and Array approaches also support swapping transparent colors, not only opaque ones, so keep that in mind when designing your palettes.

Transparent color swapping support illustration
Illustration of the transparent color swapping support

📚 Documentation

This project is fully documented so that you can understand what each function or property does, just check it out in the eye_dropper.gdshader file!

🧪 Testing

This project was manually tested with Godot 4.3. Automatic tests weren't written since GDShaders generally can't be tested that way, at least to my knowledge.

🤝 Contributing

If you like this project, consider supporting me on Ko-fi so I can keep on making content like this! :D

Buy Me a Coffee at ko-fi.com

Other than that, here are some ways you can contribute to this project, so that we can improve it together:

  • If you found a bug, feel free to create an Issue pointing it out. The more informations the better. Also, including a Minimal Reproduction Project would go a long way;

  • If you see an Issue that you think you can help with, give it a try! :)

Credits

Shader created with ❤️ by @nadjiel

I hope this shader can help you with your projects! :D

About

Eye Dropper is a shader for Godot (using gdshader language) that allows performing color palette swapping in an intuitive way.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published