subtype idKGScriptParserduration?đ framebaseencodingparms inputFormat inputCountpublicbogtitlemore filters atuitype typedefaultstringvaluespudwww.fxscript.org stringyuvrgb colour spaceuiinfolabelsRGBYUVmin?€max@?€?€amounteffect strength#$?€?€?€ rgb_balance rgb/yuv slope#ÂČ$BČBHBHrbalance r/y slope#ÂČ$BČBHBHgbalance g/u slope#ÂČ$BČBHBHbbalance b/v slope#ÂČ$BČBHBH rgb_offsetrgb/yuv offset#À$C€rampA roffset r/y offset#À$C€7A goffset g/u offset#À$C€7A boffset b/v offset#À$C€7A rgb_gamma rgb/yuv gamma#$@€?€?€rgamma r/y gamma#$@€?€?€ggamma g/u gamma#$@€?€?€bgamma b/v gamma#$@€?€?€ rgb_sinusoidrgb/yuv film curve#ż€$?€ rsinusoidr/y film curve#ż€$?€ gsinusoidg/u film curve#ż€$?€ bsinusoidb/v film curve#ż€$?€graphondraw graph (preview only)#$privatestaticsscript†//--------------------------------// // Stib's Colour Engine // //for more visit www.fxscript.org // //--------------------------------// //copyright 2003-2005 stephen dixon //This software is free - you may modify and distribute it as you wish as long as: //* the source remains open //*you clearly identify my code as the basis for the modification //* this message remains with the source //this software is released under the terms of the GNU Public license //this software comes with no warranty of fitness for any purpose whatsoever, ok? //if you like it or if you do something creative with it let me know, I'd love to hear from you. //colour engine is a rename of my old colouriser plugin, if you're wondering. filter "colour engine 3.0"; group "stib's filters"; // an all purpose, industrial strength, YUV aware colour tool using CLUTs input bog, "more filters at", Label, "string" input spud, "www.fxscript.org", Label, "string" input YUVRGB, "colour space", RadioGroup, 1, "RGB", "YUV" input amount, "effect strength", slider, 1, 0, 1; input rgb_Balance, "rgb/yuv slope", slider, 50, -100, 100; input rBalance, "r/y slope", slider, 50, -100, 100; input gBalance, "g/u slope", slider, 50, -100, 100; input bBalance, "b/v slope", slider, 50, -100, 100; input rgb_Offset, "rgb/yuv offset", slider, 0, -256, 256 ramp 10; input rOffset, "r/y offset", slider, 0, -256, 256 ramp 10; input gOffset, "g/u offset", slider, 0, -256, 256 ramp 10; input bOffset, "b/v offset", slider, 0, -256, 256 ramp 10; input rgb_Gamma, "rgb/yuv gamma", slider, 1, 0, 4; input rGamma, "r/y gamma", slider, 1, 0, 4; input gGamma, "g/u gamma", slider, 1, 0, 4; input bGamma, "b/v gamma", slider, 1, 0, 4; input rgb_Sinusoid, "rgb/yuv film curve", slider, 0, -1, 1; input rSinusoid, "r/y film curve", slider, 0, -1, 1; input gSinusoid, "g/u film curve", slider, 0, -1, 1; input bSinusoid, "b/v film curve", slider, 0, -1, 1; input GraphOn, "draw graph (preview only)", CheckBox, true InformationFlag("YUVaware") //new for version 3.0! code rgb_Balance -= 50; //munge our slider values into something more useful rgb_Gamma -=1; float i, clut_RGB[3][256], RGBBalance[3], RGBOffset[3], RGBGamma[3], RGBSinusoid[3] float ColourChannel,w, h; dimensionsof(dest, w, h); //get dimensions for our image buffers image YUVRGBBuffer[w][h], buf1[w][h]; //load the slider values into some arrays RGBBalance = {rBalance+rgb_Balance, gBalance+rgb_Balance, bBalance+rgb_Balance}; RGBOffset = {rOffset+rgb_Offset, gOffset+rgb_Offset, bOffset+rgb_Offset}; RGBGamma = {rGamma+rgb_Gamma, gGamma+rgb_Gamma, bGamma+rgb_Gamma}; RGBSinusoid = {rSinusoid+rgb_Sinusoid, gSinusoid+rgb_Sinusoid, bSinusoid+rgb_Sinusoid}; // the r, g & b Balance sliders provide the an input to output function of the form y = a(x^b)+c+d.sin(kx) // here we plot the graph into CLUTs. for ColourChannel = 0 to 2 if (amount + RGBBalance[ColourChannel] + RGBOffset[ColourChannel]+ RGBGamma[ColourChannel] +RGBSinusoid[ColourChannel]!=51) then //skip all this pallaver if the level slider is not changed for i = 0 to 255 clut_RGB[ColourChannel][i] = i * (1-amount)/255 + amount * ((RGBBalance[ColourChannel]/50 * Power(i/255, RGBGamma[ColourChannel])) + RGBOffset[ColourChannel]/255 + (0-RGBSinusoid[ColourChannel])/2*(RGBBalance[ColourChannel]/50*sin(i/255*360))) ; // ooh that's an ugly one. the default slope + overall level control * (( slope * gamma ) + offset + sinusoidality) // I used to have checks for values > 256 and <0 here but you don't need em -levelmap takes care of this itself next; else clut_RGB[ColourChannel] = LinearRamp end if; next; if (GetPixelFormat(src1) != kFormatYUV219) && (YUVRGB != 1); //convert RGB to YUV if source footage is RGB and user has selected YUV //process as YUV setPixelFormat(YUVRGBBuffer, kFormatYUV219); ConvertImage(src1, YUVRGBBuffer, kFormatYUV219); levelmap(YUVRGBBuffer, buf1, LinearRamp, clut_RGB[0], clut_RGB[1], clut_RGB[2]); if (GetPixelFormat(dest) != kFormatYUV219) //our buffer is in a different colour space to our dest ConvertImage(buf1, dest, GetPixelFormat(dest)); //could be rgb255 or rgb219 so we get the format rather than set it explicitly else dest = buf1 //the buffer and dest are in the same colour space so just dump it out end if else if (GetPixelFormat(src1) == kFormatYUV219) && (YUVRGB == 1); //convert YUV to RGB if source footage is YUV and user has selected RGB //process as RGB setPixelFormat(YUVRGBBuffer, kFormatRGB255); ConvertImage(src1, YUVRGBBuffer, GetPixelFormat(src1)); levelmap(YUVRGBBuffer, buf1, LinearRamp, clut_RGB[0], clut_RGB[1], clut_RGB[2]); if (GetPixelFormat(dest) == kFormatYUV219) ConvertImage(buf1, dest, kFormatYUV219); else dest = buf1 //the buffer and dest are in the same colour space so just dump it out end if else //process in the native format without conversion levelmap(src1, dest, LinearRamp, clut_RGB[0], clut_RGB[1], clut_RGB[2]); end if if GraphOn && previewing{ //only draw the graph in previews, so you don't have to worry about turning it off for final renders float screenwidth, screenheight color lineColour[3]; string labelStr[3]; point Xleft ,Xright , Ytop, RgraphPoint , GgraphPoint , BgraphPoint DimensionsOf(dest, screenwidth, screenheight); screenheight *= 0.8; screenwidth *= 0.8; Xleft = {0-screenwidth/2, screenheight/2} Xright = {screenwidth/2, screenheight/2} Ytop = {screenwidth/2, 0-screenheight/2} Line(Xleft , Xright , dest, kwhite, 2) Line(Xright , Ytop , dest, kwhite, 2) //x & y axes if YUVRGB == 1 lineColour[0] = {0,255,0,0} lineColour[1] = {0,0,255,0}; lineColour[2] = {0,0,0,255}; //for some reason I couldn't do all this in one line. It kept chucking errors. labelStr[0] = "r" labelStr[1] = "g" labelStr[2] = "b" else lineColour[0] = {0,255,255,255} lineColour[1] = {0,0,255,255}; lineColour[2] = {0,255,255,0}; labelStr[0] = "y" labelStr[1] = "u" labelStr[2] = "v" end if; for ColourChannel = 0 to 2 for i = 0 to 255 if clut_RGB[ColourChannel][i] > 0 and clut_RGB[ColourChannel][i] < 1 RgraphPoint = {i/256*screenwidth - screenwidth/2,(screenheight/2)-clut_RGB[ColourChannel][i]*screenheight}; DrawSoftDot(Dest, RgraphPoint, kRound, 3, 5, 1, lineColour[ColourChannel], 100, 1) // plot the red graph end if next; DrawString(labelStr[ColourChannel], RgraphPoint.X, RgraphPoint.Y, 10, dest, lineColour[ColourChannel], 1) next; end if; namecolour engine 3.0scriptidcgroupstib's filtersYUVawareencoded