• Create Account

### #ActualMekuri

Posted 20 February 2013 - 04:11 PM

Hey again.

So I tried out a few solutions as you guys suggested, and ended up with a solution (Skip ahead to solution if you don't want to read about my experiences).

First off I tried averaging the values  ((a + b) / 2), but the results weren't great. At higher light levels it actually seemed to work out, but when I went into the darker areas, the colors would not be dimmed enough.

I then tried to convert the values to a float between 0.0 - 1.0 by doing like this:

float r = ((_hairColor.R / 255) * (_lightColor.R / 255)) * 255. I did this for the B and G value as well. This gave me two different results. This would cause the hair to be black, unless the area was very light, which would turn the hair red (in the case the hair should be blonde/yellow). If I then added an f after all the 255 in the code (to make sure it was treated as floats) the hair reacted similar to when I took the average values.

Solution

So I looked back here and noticed this:

I also like using Seabolt's 'convert to 0.0 - 1.0 floats and multiply' method.

So I quickly went back and ended up with the following code:

float scale = lightLevel / 255f;
Color modifiedHairColor = Color.Multiply(_hairColor, scale);
Color modifiedChestColor = Color.Multiply(_chestColor, scale);
Color modfifiedLegColor = Color.Multiply(_legColor, scale);


I've seen the multiply method before, but never really realized how to use it, until now

So that was the end result, and it seems to be working out. I've tested in very dark areas and very lit areas, and it works just as I wanted it to.

Thanks a lot for the awesome and fast feedback, it is really appreciated.

Also Osmanb I've bookmarked the link you provided. I am currently taking math classes so I might want to look it over in the weekend, thanks!

EDIT:

So just after I posted this I realized that a little change was needed for this to work properly. When using the multiply method with a scale, it seems it also applies to the Alpha value of the color. This is simply fixed my setting the alpha value to 255 (or any other value needed). Just figured I'd add that.

### #2Mekuri

Posted 20 February 2013 - 04:10 PM

Hey again.

So I tried out a few solutions as you guys suggested, and ended up with a solution (Skip ahead to solution if you don't want to read about my experiences).

First off I tried averaging the values  ((a + b) / 2), but the results weren't great. At higher light levels it actually seemed to work out, but when I went into the darker areas, the colors would not be dimmed enough.

I then tried to convert the values to a float between 0.0 - 1.0 by doing like this:

float r = ((_hairColor.R / 255) * (_lightColor.R / 255)) * 255. I did this for the B and G value as well. This gave me two different results. This would cause the hair to be black, unless the area was very light, which would turn the hair red (in the case the hair should be blonde/yellow). If I then added an f after all the 255 in the code (to make sure it was treated as floats) the hair reacted similar to when I took the average values.

Solution

So I looked back here and noticed this:

I also like using Seabolt's 'convert to 0.0 - 1.0 floats and multiply' method.

So I quickly went back and ended up with the following code:

float scale = lightLevel / 255f;
Color modifiedHairColor = Color.Multiply(_hairColor, scale);
Color modifiedChestColor = Color.Multiply(_chestColor, scale);
Color modfifiedLegColor = Color.Multiply(_legColor, scale);


I've seen the multiply method before, but never really realized how to use it, until now

So that was the end result, and it seems to be working out. I've tested in very dark areas and very lit areas, and it works just as I wanted it to.

Thanks a lot for the awesome and fast feedback, it is really appreciated.

Also Osmanb I've bookmarked the link you provided. I am currently taking math classes so I might want to look it over in the weekend, thanks!

EDIT:

So just after I posted this I realized that a little change is needed for this to work properly. When using the multiply method with a scale, it seems it also applies to the Alpha value of the color. This is simply fixed my setting the alpha value to 255 (or any other value needed). Just figured I'd add that.

### #1Mekuri

Posted 20 February 2013 - 03:41 PM

Hey again.

So I tried out a few solutions as you guys suggested, and ended up with a solution (Skip ahead to solution if you don't want to read about my experiences).

First off I tried averaging the values  ((a + b) / 2), but the results weren't great. At higher light levels it actually seemed to work out, but when I went into the darker areas, the colors would not be dimmed enough.

I then tried to convert the values to a float between 0.0 - 1.0 by doing like this:

float r = ((_hairColor.R / 255) * (_lightColor.R / 255)) * 255. I did this for the B and G value as well. This gave me two different results. This would cause the hair to be black, unless the area was very light, which would turn the hair red (in the case the hair should be blonde/yellow). If I then added an f after all the 255 in the code (to make sure it was treated as floats) the hair reacted similar to when I took the average values.

Solution

So I looked back here and noticed this:

I also like using Seabolt's 'convert to 0.0 - 1.0 floats and multiply' method.

So I quickly went back and ended up with the following code:

float scale = lightLevel / 255f;
Color modifiedHairColor = Color.Multiply(_hairColor, scale);
Color modifiedChestColor = Color.Multiply(_chestColor, scale);
Color modfifiedLegColor = Color.Multiply(_legColor, scale);


I've seen the multiply method before, but never really realized how to use it, until now

So that was the end result, and it seems to be working out. I've tested in very dark areas and very lit areas, and it works just as I wanted it to.

Thanks a lot for the awesome and fast feedback, it is really appreciated.

Also Osmanb I've bookmarked the link you provided. I am currently taking math classes so I might want to look it over in the weekend, thanks!

PARTNERS