Question
I have quite number of sprites in my game. I want the player be able to change the color of them.
- I can create textures (from .png) that has different colored sprites of the ‘same’ thing. When the player selects a color, it’ll switch to that colored texture.
- Or I can create a ‘base white’ texture and modulate the color. So when the player selects a color, it’ll change the color modulate property of the node, using the same texture.
In terms of performance (or for other things I cannot think of), what’s the advantage/disadvantage of choosing one of these solutions?
Are the sprites highly detailed? if then I don’t think it would look good by changing the modulate and having individual sprites for each colors are also not very good. can you share the sprite of your player?
also,is it pixel art or hand-drawn? you can try to break the sprite details into pure white layers and then use modulate to color em like this
They are not detailed. The sprites consist of :
- an outline (black-ish)
- a fill color that can have some gradient or not..
I tried both (modulating and regular texture). They both look fine for my case. I’m asking this question to see if it’s worth to give the player the freedom of changing whatever color they want or just limiting it to a pre-selected number of colors.
I do hand-drawn (on computer). I do break the sprites as you suggested. The outline sprite is not modulated. The color sprite is modulated.
But if I use pre-selected textures, then I’d have only one sprite for each item, not two, depending on the color customization.
you should maybe give the player freedom to do with custom colors cuz why not xD
Yes, I agree. But then what performance costs it may come with, is my question. I can always start with the custom color and go back to the pre-defined colors.
are there multiple instances of the player
All sprites (in fact all canvas items) are always modulated, just that the default modulation color is white. Changing modulation color doesn’t affect performance.
1 Like
It’s not player. They are the items that you can interact within the game. So yes there will be multiple instances of an item. And there will be different items as well.
I don’t think just changing the color of a player would then cost any performance at all.
Then it means my performance cost-adder is the extra sprite2Ds required for each individual color modulation (or outline) for each item, compared to one sprite2D.
It’ll likely be negligible. Watch out for premature optimization trap.
2 Likes