Jump to content

Color Blending - Strange Float value testing results?


Ruthven Ravenhurst
 Share

You are about to reply to a thread that has been inactive for 2463 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I'm working on a theoretical approach to blending LSL color vectors, and saw what I think is strange behavior in the float value test, maybe I'm wrong?

In the test for each element of the vector, I have it check if the value is more than 0.99, change it to 1.00, and if it's less than 0.00 change it to 0.00 (0.00743453 should convert to 0.00). It seems to be working on the 0.99 test, but not the 0.00 test. Script below, and text below that to show how many times I had to click the face representing black to get it to change the vector fully to black

list colors = [<1.000000, 0.000000, 0.000000>, <0.000000, 1.000000, 0.000000>, <0.000000, 0.000000, 1.000000>, <1.000000, 1.000000, 0.000000>, <1.000000, 0.000000, 0.501961>, <0.000000, 1.000000, 1.000000>, <0.000000, 0.000000, 0.000000>, <1.000000, 1.000000, 1.000000>];

float scale = 0.15;
default
{
    state_entry()
    {
        llSetColor(<1.0,1.0,1.0>,ALL_SIDES);
    }

    touch_start(integer total_number)
    {
        integer link = llDetectedLinkNumber(0);
        if(link > 1)
        {
            integer face = llDetectedTouchFace(0);
            vector c1 = llGetColor(0);
            vector c2 = llList2Vector(colors,face);
            vector newcolor = (c1*(1-scale)) + (c2*scale);
            if(newcolor.x < 0.00)newcolor.x = 0.00;
            if(newcolor.x > 0.99)newcolor.x = 1.00;
            if(newcolor.y < 0.00)newcolor.y = 0.00;
            if(newcolor.y > 0.99)newcolor.y = 1.00;
            if(newcolor.z < 0.00)newcolor.z = 0.00;
            if(newcolor.z > 0.99)newcolor.z = 1.00;
            llSay(0,(string)newcolor);
            llSetColor(newcolor,ALL_SIDES);
        }
        else
        {
            llResetScript();
        }
    }
}
Object: <0.01056, 0.01056, 0.01056>
Object: <0.00898, 0.00898, 0.00898>
Object: <0.00763, 0.00763, 0.00763>
Object: <0.00649, 0.00649, 0.00649>
Object: <0.00551, 0.00551, 0.00551>
Object: <0.00469, 0.00469, 0.00469>
Object: <0.00398, 0.00398, 0.00398>
Object: <0.00339, 0.00339, 0.00339>
Object: <0.00288, 0.00288, 0.00288>
Object: <0.00245, 0.00245, 0.00245>
Object: <0.00208, 0.00208, 0.00208>
Object: <0.00177, 0.00177, 0.00177>
Object: <0.00150, 0.00150, 0.00150>
Object: <0.00128, 0.00128, 0.00128>
Object: <0.00109, 0.00109, 0.00109>
Object: <0.00092, 0.00092, 0.00092>
Object: <0.00078, 0.00078, 0.00078>
Object: <0.00067, 0.00067, 0.00067>
Object: <0.00057, 0.00057, 0.00057>
Object: <0.00048, 0.00048, 0.00048>
Object: <0.00041, 0.00041, 0.00041>
Object: <0.00035, 0.00035, 0.00035>
Object: <0.00030, 0.00030, 0.00030>
Object: <0.00025, 0.00025, 0.00025>
Object: <0.00021, 0.00021, 0.00021>
Object: <0.00018, 0.00018, 0.00018>
Object: <0.00015, 0.00015, 0.00015>
Object: <0.00013, 0.00013, 0.00013>
Object: <0.00011, 0.00011, 0.00011>
Object: <0.00009, 0.00009, 0.00009>
Object: <0.00008, 0.00008, 0.00008>
Object: <0.00007, 0.00007, 0.00007>
Object: <0.00006, 0.00006, 0.00006>
Object: <0.00005, 0.00005, 0.00005>
Object: <0.00004, 0.00004, 0.00004>
Object: <0.00004, 0.00004, 0.00004>
Object: <0.00003, 0.00003, 0.00003>
Object: <0.00003, 0.00003, 0.00003>
Object: <0.00002, 0.00002, 0.00002>
Object: <0.00002, 0.00002, 0.00002>
Object: <0.00002, 0.00002, 0.00002>
Object: <0.00001, 0.00001, 0.00001>
Object: <0.00001, 0.00001, 0.00001>
Object: <0.00001, 0.00001, 0.00001>
Object: <0.00001, 0.00001, 0.00001>
Object: <0.00001, 0.00001, 0.00001>
Object: <0.00001, 0.00001, 0.00001>
Object: <0.00001, 0.00001, 0.00001>
Object: <0.00000, 0.00000, 0.00000>

 

Link to comment
Share on other sites

14 minutes ago, Ruthven Willenov said:

I'm working on a theoretical approach to blending LSL color vectors, and saw what I think is strange behavior in the float value test, maybe I'm wrong?

In the test for each element of the vector, I have it check if the value is more than 0.99, change it to 1.00, and if it's less than 0.00 change it to 0.00 (0.00743453 should convert to 0.00). It seems to be working on the 0.99 test, but not the 0.00 test. Script below, and text below that to show how many times I had to click the face representing black to get it to change the vector fully to black


list colors = [<1.000000, 0.000000, 0.000000>, <0.000000, 1.000000, 0.000000>, <0.000000, 0.000000, 1.000000>, <1.000000, 1.000000, 0.000000>, <1.000000, 0.000000, 0.501961>, <0.000000, 1.000000, 1.000000>, <0.000000, 0.000000, 0.000000>, <1.000000, 1.000000, 1.000000>];

float scale = 0.15;
default
{
    state_entry()
    {
        llSetColor(<1.0,1.0,1.0>,ALL_SIDES);
    }

    touch_start(integer total_number)
    {
        integer link = llDetectedLinkNumber(0);
        if(link > 1)
        {
            integer face = llDetectedTouchFace(0);
            vector c1 = llGetColor(0);
            vector c2 = llList2Vector(colors,face);
            vector newcolor = (c1*(1-scale)) + (c2*scale);
            if(newcolor.x < 0.00)newcolor.x = 0.00;
            if(newcolor.x > 0.99)newcolor.x = 1.00;
            if(newcolor.y < 0.00)newcolor.y = 0.00;
            if(newcolor.y > 0.99)newcolor.y = 1.00;
            if(newcolor.z < 0.00)newcolor.z = 0.00;
            if(newcolor.z > 0.99)newcolor.z = 1.00;
            llSay(0,(string)newcolor);
            llSetColor(newcolor,ALL_SIDES);
        }
        else
        {
            llResetScript();
        }
    }
}

Object: <0.01056, 0.01056, 0.01056>
Object: <0.00898, 0.00898, 0.00898>
Object: <0.00763, 0.00763, 0.00763>
Object: <0.00649, 0.00649, 0.00649>
Object: <0.00551, 0.00551, 0.00551>
Object: <0.00469, 0.00469, 0.00469>
Object: <0.00398, 0.00398, 0.00398>
Object: <0.00339, 0.00339, 0.00339>
Object: <0.00288, 0.00288, 0.00288>
Object: <0.00245, 0.00245, 0.00245>
Object: <0.00208, 0.00208, 0.00208>
Object: <0.00177, 0.00177, 0.00177>
Object: <0.00150, 0.00150, 0.00150>
Object: <0.00128, 0.00128, 0.00128>
Object: <0.00109, 0.00109, 0.00109>
Object: <0.00092, 0.00092, 0.00092>
Object: <0.00078, 0.00078, 0.00078>
Object: <0.00067, 0.00067, 0.00067>
Object: <0.00057, 0.00057, 0.00057>
Object: <0.00048, 0.00048, 0.00048>
Object: <0.00041, 0.00041, 0.00041>
Object: <0.00035, 0.00035, 0.00035>
Object: <0.00030, 0.00030, 0.00030>
Object: <0.00025, 0.00025, 0.00025>
Object: <0.00021, 0.00021, 0.00021>
Object: <0.00018, 0.00018, 0.00018>
Object: <0.00015, 0.00015, 0.00015>
Object: <0.00013, 0.00013, 0.00013>
Object: <0.00011, 0.00011, 0.00011>
Object: <0.00009, 0.00009, 0.00009>
Object: <0.00008, 0.00008, 0.00008>
Object: <0.00007, 0.00007, 0.00007>
Object: <0.00006, 0.00006, 0.00006>
Object: <0.00005, 0.00005, 0.00005>
Object: <0.00004, 0.00004, 0.00004>
Object: <0.00004, 0.00004, 0.00004>
Object: <0.00003, 0.00003, 0.00003>
Object: <0.00003, 0.00003, 0.00003>
Object: <0.00002, 0.00002, 0.00002>
Object: <0.00002, 0.00002, 0.00002>
Object: <0.00002, 0.00002, 0.00002>
Object: <0.00001, 0.00001, 0.00001>
Object: <0.00001, 0.00001, 0.00001>
Object: <0.00001, 0.00001, 0.00001>
Object: <0.00001, 0.00001, 0.00001>
Object: <0.00001, 0.00001, 0.00001>
Object: <0.00001, 0.00001, 0.00001>
Object: <0.00001, 0.00001, 0.00001>
Object: <0.00000, 0.00000, 0.00000>

 

Don't you want if x<0.01? It's never going to be less than zero.

Link to comment
Share on other sites

1 minute ago, Rachel1206 said:

Precision of the LSL colors entries are 3 digits, so yu need to round the float values according to this.

 

 

ah ok, did not know that. works beautifully now

list colors = [<1.000000, 0.000000, 0.000000>, <0.000000, 1.000000, 0.000000>, <0.000000, 0.000000, 1.000000>, <1.000000, 1.000000, 0.000000>, <1.000000, 0.000000, 0.501961>, <0.000000, 1.000000, 1.000000>, <0.000000, 0.000000, 0.000000>, <1.000000, 1.000000, 1.000000>];

float scale = 0.15;
default
{
    state_entry()
    {
        llSetColor(<1.0,1.0,1.0>,ALL_SIDES);
    }

    touch_start(integer total_number)
    {
        integer link = llDetectedLinkNumber(0);
        if(link > 1)
        {
            integer face = llDetectedTouchFace(0);
            vector c1 = llGetColor(0);
            vector c2 = llList2Vector(colors,face);
            vector newcolor = (c1*(1-scale)) + (c2*scale);
            if(newcolor.x < 0.001)newcolor.x = 0.00;
            if(newcolor.x > 0.999)newcolor.x = 1.00;
            if(newcolor.y < 0.001)newcolor.y = 0.00;
            if(newcolor.y > 0.999)newcolor.y = 1.00;
            if(newcolor.z < 0.001)newcolor.z = 0.00;
            if(newcolor.z > 0.999)newcolor.z = 1.00;
            llSay(0,(string)newcolor);
            llSetColor(newcolor,ALL_SIDES);
        }
        else
        {
            llResetScript();
        }
    }
}

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2463 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...