• Create Account

### #ActualYura

Posted 16 January 2013 - 05:56 AM

i think i understand what your doing, the key point here is what is the function you use to map your data points to your pallete?

for example, if i said, give me the pallete to use at x = 0, y = 0(using your data set from your sample, and in your sample is red), then what is your code for figuring out to choose red?
I'm just finding min and max value (on points) and splitting the range on 12 levels (12 colors in palette)
float step = (Math.Abs(min) + Math.Abs(max)) / 12;
and then I just calculate in what period input value belongs to:
if ((val >= levels[0]) && (val < levels[1]))            {                return 0.082f;            }            if ((val >= levels[1]) && (val < levels[2]))            {                return 0.164f;            }
And return float value, which apply to the texture above. For example 0-0.083 in my texture is blue and 9.8-9.999 is red. I'm using this returned values as coordinated of my texture.

EDIT: Tryed to implement your function. Created new texture, BUT: have no idea how to calculate "YourFormulaForLookingUpTheColorAtASepeceficPoint(x, y);". I have 4 points on element, for example I'm creating 24x24 texture. How can I choose color for 576 inner texels, when I know only 4 of them?

### #1Yura

Posted 16 January 2013 - 01:55 AM

i think i understand what your doing, the key point here is what is the function you use to map your data points to your pallete?

for example, if i said, give me the pallete to use at x = 0, y = 0(using your data set from your sample, and in your sample is red), then what is your code for figuring out to choose red?

I'm just finding min and max value (on points) and splitting the range on 12 levels (12 colors in palette)

float step = (Math.Abs(min) + Math.Abs(max)) / 12;

and then I just calculate in what period input value belongs to:

 if ((val >= levels[0]) && (val < levels[1]))
{
return 0.082f;
}
if ((val >= levels[1]) && (val < levels[2]))
{
return 0.164f;
}

And return float value, which apply to the texture above. For example 0-0.083 in my texture is blue and 9.8-9.999 is red. I'm using this returned values as coordinated of my texture.

PARTNERS