I have a quick question for those who know XNA and Color theory in computer graphics well. I am making a tile game (a bit like Terraria), and I was wondering how to go about applying per-tile lighting to the scene. Colored lighting is a must for this game, and right now I got about that by having 4 2D byte arrays, storing overall light and the 3 different color amounts. When the tiles are drawn, it takes the texture of the specific tile its at, but how would I go about applying the color at the same tile based on the 3 color values and overall lighting?
Right now, this is my Color generating function:
public Color GetColorAt(int x, int y)
{
byte r = _rMap[x, y]; //Red light
byte g = _gMap[x, y]; //Green light
byte b = _bMap[x, y]; //Blue light
byte mul = _lightMap[x, y]; ///Overall light
return new Color(r * mul, g * mul, b * mul, 1);
}
Being new at color theory, I have no idea if I am going about this in the right way at all. My lighting system uses a cellular algorithm, decreasing and spreading out to all adjacent tiles. If it decreases the color values each tile, do I even need the overall light value to begin with?
Also, when it comes to blending the tile textures and light to get the result, do I use addition, or multiplication, or some other calculation?
TL;DR: 1. Does the code block above work, considering the light decreases between each tile? 2. How do I combine light and textures to get a texture that looks like its under the color of light?
Thanks for any help, I have no experience with Color combining.