Actionscript 3 像素混合器的色调错误。flash/actionscript

Actionscript 3 像素混合器的色调错误。flash/actionscript,actionscript-3,flash,actionscript,pixel-bender,Actionscript 3,Flash,Actionscript,Pixel Bender,我有一个javascript可以选择颜色(HSB)。但在我的闪光元素中,色调的计算是错误的 我有这个输入例如:色调:360。。。SAT:100..亮度:97但flash元素的颜色不正确。怎么办?我正在使用PixelBlender更改每个像素的颜色 这是我的色调。PBJ: <languageVersion : 1.0;> kernel HSLFilter < namespace : "Boostworthy::Filters"; vendor : "R

我有一个javascript可以选择颜色(HSB)。但在我的闪光元素中,色调的计算是错误的

我有这个输入例如:色调:360。。。SAT:100..亮度:97但flash元素的颜色不正确。怎么办?我正在使用PixelBlender更改每个像素的颜色

这是我的色调。PBJ:

 <languageVersion : 1.0;>

 kernel HSLFilter
 <   
namespace   : "Boostworthy::Filters";
vendor      : "Ryan Taylor";
version     : 1;
description : "";
>
{
 parameter   float       hue
 < 
    minValue        :   0.0;
    maxValue        :   360.0;
    defaultValue    :   360.0;
  >;

parameter   float       saturation
<
    minValue        :   0.0;
    maxValue        :   100.0;
    defaultValue    :   0.0;
>;

parameter   float       lightness
<
    minValue        :   0.0;
    maxValue        :   100.0;
    defaultValue    :   0.0;
>;

input       image4      source;
output      pixel4      result;

void evaluatePixel()
{
    // Convert sampled pixel from RGB space to HSL space.

    pixel4 samp;
    float  sampMin;
    float  sampMax;
    float  sampDiff;
    float  sampSum;
    float  sampH;
    float  sampS;
    float  sampL;

    samp     = sampleNearest(source, outCoord());
    sampMin  = min(samp.r,  samp.g);
    sampMin  = min(sampMin, samp.b);
    sampMax  = max(samp.r,  samp.g);
    sampMax  = max(sampMax, samp.b);
    sampDiff = sampMax - sampMin;
    sampSum  = sampMax + sampMin;
    sampL    = sampSum * 0.5;

    if(sampMin == sampMax)
        sampH = 0.0;
    else if(sampMax == samp.r)
        sampH = mod(60.0 * ((samp.g - samp.b) / sampDiff), 360.0);
    else if(sampMax == samp.g)
        sampH = 60.0 * ((samp.b - samp.r) / sampDiff) + 120.0;
    else if(sampMax == samp.b)
        sampH = 60.0 * ((samp.r - samp.g) / sampDiff) + 240.0;
    else
        sampH = 0.0;

    if(sampMin == sampMax)
        sampS = 0.0;
    else if(sampL > 0.5)
        sampS = sampDiff / (2.0 - sampSum);
    else
        sampS = sampDiff / sampSum;

    // Transform the sampled HSL values by the amounts specified
    // by the hue, saturation, and lightness parameters.

    float outH;
    float outS;
    float outL;

    outH  = sampH - hue;
    outS  = sampS * (saturation / 100.0 + 1.0);
    outL  = sampL - (1.0 - (lightness / 100.0 + 1.0));

    // Convert the transformed HSL values back to RGB space.

    float q;
    float p;
    float h;

    if(outL < 0.5)
        q = outL * (1.0 + outS);
    else
        q = outL + outS - outL * outS;

    p = 2.0 * outL - q;
    h = outH / 360.0;

    float  oneOverThree = 1.0 / 3.0;
    float  twoOverThree = 2.0 / 3.0;
    float  oneOverSix   = 1.0 / 6.0;
    float3 t            = float3(h + oneOverThree, h, h - oneOverThree);

    if(t.r < 0.0)
        t.r += 1.0;
    else if(t.r > 1.0)
        t.r -= 1.0;

    if(t.g < 0.0)
        t.g += 1.0;
    else if(t.g > 1.0)
        t.g -= 1.0;

    if(t.b < 0.0)
        t.b += 1.0;
    else if(t.b > 1.0)
        t.b -= 1.0;

    pixel4 c = pixel4(0.0, 0.0, 0.0, samp.a);

    if(t.r < oneOverSix)
        c.r = p + (q - p) * 6.0 * t.r;
    else if(t.r >= oneOverSix && t.r < 0.5)
        c.r = q;
    else if(t.r >= 0.5 && t.r < twoOverThree)
        c.r = p + (q - p) * 6.0 * (twoOverThree - t.r);
    else
        c.r = p;

    if(t.g < oneOverSix)
        c.g = p + (q - p) * 6.0 * t.g;
    else if(t.g >= oneOverSix && t.g < 0.5)
        c.g = q;
    else if(t.g >= 0.5 && t.g < twoOverThree)
        c.g = p + (q - p) * 6.0 * (twoOverThree - t.g);
    else
        c.g = p;

    if(t.b < oneOverSix)
        c.b = p + (q - p) * 6.0 * t.b;
    else if(t.b >= oneOverSix && t.b < 0.5)
        c.b = q;
    else if(t.b >= 0.5 && t.b < twoOverThree)
        c.b = p + (q - p) * 6.0 * (twoOverThree - t.b);
    else
        c.b = p;

    // Apply the final ARGB color to the pixel.

    result = c;
}
} 

内核高速滤波器
<   
名称空间:“Boostworthy::Filters”;
供应商:“Ryan Taylor”;
版本:1;
说明:“;
>
{
参数浮动色调
< 
最小值:0.0;
最大值:360.0;
默认值:360.0;
>;
参数浮动饱和
<
最小值:0.0;
最大值:100.0;
默认值:0.0;
>;
参数浮动亮度
<
最小值:0.0;
最大值:100.0;
默认值:0.0;
>;
输入image4源;
输出像素4结果;
void evaluatePixel()
{
//将采样像素从RGB空间转换为HSL空间。
pixel4-samp;
浮动sampMin;
浮动sampMax;
浮动sampDiff;
浮子;
漂浮的桑夫;
浮动样本;
浮动采样;
samp=sampleNearest(source,outCoord());
sampMin=min(samp.r,samp.g);
sampMin=min(sampMin,samp.b);
sampMax=最大值(samp.r,samp.g);
sampMax=max(sampMax,samp.b);
sampDiff=sampMax-sampMin;
sampSum=sampMax+sampMin;
sampL=sampSum*0.5;
if(sampMin==sampMax)
sampH=0.0;
else if(sampMax==samp.r)
sampH=mod(60.0*((samp.g-samp.b)/sampDiff),360.0);
else if(sampMax==samp.g)
sampH=60.0*((samp.b-samp.r)/sampDiff)+120.0;
else if(sampMax==samp.b)
sampH=60.0*((samp.r-samp.g)/sampDiff)+240.0;
其他的
sampH=0.0;
if(sampMin==sampMax)
sampS=0.0;
否则如果(sampL>0.5)
sampS=sampDiff/(2.0-sampSum);
其他的
sampS=sampDiff/sampSum;
//按指定的量转换采样的HSL值
//通过色调、饱和度和亮度参数。
浮出水面;
浮出水面;
浮出水面;
outH=色相;
输出=采样点*(饱和/100.0+1.0);
outL=sampL-(1.0-(亮度/100.0+1.0));
//将转换后的HSL值转换回RGB空间。
浮点数q;
浮动p;
浮动h;
如果(outL<0.5)
q=输出*(1.0+输出);
其他的
q=输出+输出-输出*输出;
p=2.0*outL-q;
h=outH/360.0;
浮点数1翻转=1.0/3.0;
浮动二次翻转=2.0/3.0;
浮动oneOverSix=1.0/6.0;
float3t=float3(h+one翻转,h,h-one翻转);
如果(t.r<0.0)
t、 r+=1.0;
否则如果(t.r>1.0)
t、 r-=1.0;
如果(t.g<0.0)
t、 g+=1.0;
否则如果(t.g>1.0)
t、 g-=1.0;
如果(t.b<0.0)
t、 b+=1.0;
否则如果(t.b>1.0)
t、 b-=1.0;
pixel4 c=pixel4(0.0,0.0,0.0,样本a);
如果(t.r=oneOverSix和&t.r<0.5)
c、 r=q;
否则如果(t.r>=0.5&&t.r=oneOverSix和&t.g<0.5)
c、 g=q;
否则,如果(t.g>=0.5&&t.g=oneOverSix和&t.b<0.5)
c、 b=q;
否则如果(t.b>=0.5&&t.b
IIRC原始着色器版本使用-180到180色调参数,对于某些色调,您的t.b很可能低于-1,这在该着色器中是未知的。将其更改为-180到180,默认值为0,然后观看乐趣