I came across a bit of a problem when I was setting a light source color and wrote a little "corrector" function that I wanted to release if it helps anyone. It is not perfect but it works a lot better than having the color you apply not look right.
Bug listing on JIRA
vector fix_light_color(vector vIn)
{
// Create a list from our vector
list lVector = [vIn.x, vIn.y, vIn.z];
// Iterate over the 3 list values
integer i = 0;
for (;i<3;++i)
{
// Set our value to check
float fReplace = llList2Float(lVector, i);
// Set our value a power of 2
fReplace = llPow(fReplace, 2);
if (fReplace >= 0.5)
{
// If our value is greater/equal than 0.5 minus 5% of the value
fReplace = fReplace * 0.95;
}
else if (fReplace < 0.5)
{
// If our value is under 0.5 then minus 10% of the value
fReplace = fReplace * 0.90;
}
// Replace the value in the list with the one we just altered
lVector = llListReplaceList(lVector, [fReplace], i, i);
}
// return our fixed color vector from our list
return <llList2Float(lVector, 0), llList2Float(lVector, 1), llList2Float(lVector, 2)>;
}
~ Coal