I've recently finished a little character generator for my game where the player is able to customize the character by changing hair color, shirt color and pants color. I do this by having the sprite being white (or close to) and then simply tint the texture with a color, where the player can modify the RGB values. This works fine for my character generator, since there is no lighting involved there.
The problem is when you start the game. While in game, I do some tile based lighting, and the way I do that visually is by tinting all objects with the light level. For example if the player is standing next to a torch, he/she will be fully lit, thus I tint him/her with a color, where all the RGB values equals 255 (White). The darker it gets, the lower the light level.
My problem is, that I now have two colors that I use to tint the player (The color the player chose in the generator, and the light level), and I know that it is somehow possible to mix these colors.
I've tried/considered the following:
- I've tried using Color.Lerp, but I am unable to get some decent results.
- I've considered simple adding the RGB values from each color with each other, but that'll get me nowhere, since in most cases I'll end up with a pure white color, or if it is dark, the "generator color" will be shown.
- Another solution I've thought of, is rendering the sprite with the player colors (if possible) to a render target and then use that as the sprite. The problem with this is, that my sprite is divided into several parts, to accommodate coloring the individual parts, and I would have to write code separately for using render targets (instead of my current sprite sheets) for each tint-able body part.
So to sum it up:
- How would I combine two colors, one color representing a player chosen tint, the other representing a light level and get results where the player chosen color gets darker or lighter based on the light level?
If I've been unclear about how the coloring of body parts work, I have a video I made earlier today showing what I mean. If you don't want to see the whole thing, go to around 0:30 and see from there:
">
Thanks for reading :-)