How to make a sprite color custom

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By exuin

I want the user to be able to select colors for the character’s sprite, like for skin, clothes color, etc. Preferably with the color picker, but if that’s not possible I guess I could show a bunch of pre-picked colors. How would I be able to do this? Right now I’m using self_modulate but that only works for the entire sprite, not separate parts of it.

Thanks for the response, but I’m not really sure how I would do any of that in Godot. I don’t really see any mapping properties for a TextureRect. Or should I be using a Sprite instead?

exuin | 2020-09-21 19:31

ya i do it by splitting a sprite into different parts now but recently found this possible alternative…

from what i can tell if you just color your original sprite with specific shades of gray (or even colors) you can replace those specific colors with any color you chose using a shader. eg light gray = red, dark gray = blue, gray = orange

these related videos might help

https://www.youtube.com/watch?v=CLqMcgDi--Y

https://www.youtube.com/watch?v=i7VljTl4I3w

rakkarage | 2020-09-21 23:08

Thanks, I’ll probably write a shader to replace different colors in the sprite.

exuin | 2020-09-22 02:49

:bust_in_silhouette: Reply From: AticAtac

You might have to work with sprite masks. You need then separate masks for those individual parts of the sprite which you want to color. You then colorize the masks. This requires to “cut” your sprite into pieces. Thats how i did it for coloring shirts of soccer players.

How do I make a sprite mask? I don’t see any property for that in the Inspector for the Sprite node.

exuin | 2020-09-21 19:27

Your sprite mask is just a sprite itself. The way i did it was (for soccer players), i had a sprite sheet with the soccer play as one sprite and another sprite just for the shirt in grayscale. At runtime i drew the main sprite and then the colorized shirt sprite (with the right offset) on top of the main sprite.

AticAtac | 2020-09-22 15:36

Okay, thanks for the reply.

exuin | 2020-09-22 18:21