//--------------------------------------------------------------------------- // LS/IF: Sepia & Noise LScript by Alain Bertrand // // Post-process a color frame into black and white. // // if a function is not declared, LS/IF will default its behavior. The // available ImageFilter scripting functions are: // // process() called for each frame to process the selected // buffer(s) // flags() called once to specify buffers needed by plugin // options() called to interact with the user // create() called once at plugin startup to perform creation // activities // destroy() called once just prior to plugin removal to // perform shutdown activities // load() called when a scene is loaded that previously // used this script to load stored parameters // save() called when a scene is saved so that the // script may store needed parameters // // the plugin interface function copy() is not implemented as the script // maintains it own data. // // NOTE: whether the flags() function is defined or not, ImageFilter scripts // automatically have access to the RED, GREEN, BLUE, and ALPHA buffers. //--------------------------------------------------------------------------- @version 2.3 @script image gamma; // this is a global variable //----------------------------------------------------------------- // create() is invoked as soon as the script is successfully loaded // // a companion command, destroy(), is called when the script is // being shutdown (either by an explicit action of the user, or // when the Layout session is terminated). the destroy() command // is not defined in this script because we have no activities that // need to be performed during a shutdown. create { // initialize the 'gamma' value (a later load() or options() // call may alter it) setdesc("Sepia"); } //--------------------------------------------------------------------------- // every process() declaration must accept five arguments process: width, height, frame, starttime, endtime { for(i = 1;i <= height;++i) { red = bufferline(RED,i); green = bufferline(GREEN,i); blue = bufferline(BLUE,i); alpha = bufferline(ALPHA,i); for(j = 1;j <= width;++j) { intense=sqrt(red[j]*red[j]+green[j]*green[j]+blue[j]*blue[j])/255; intense=intense/random(1.5,1.7); red[j]=251*intense; green[j]=218*intense; blue[j]=160*intense; } // process the entire line at one shot processrgb(i,red,green,blue,alpha); } } //----------------------------------------------------------------- // we don't really need this function for this plugin, but it is // here for illustration flags { // available buffers are: // SPECIAL LUMINOUS DIFFUSE // MIRROR TRANS RAWRED // RAWGREEN RAWBLUE SHADING // SHADOW GEOMETRY DEPTH // (RED) (GREEN) (BLUE) (ALPHA) return(RED,GREEN,BLUE,ALPHA); // select the defaults just for fun =|^) } //----------------------------------------------------------------- // this command is invoked when the user presses the "Options" // button on the plugin interface options { } //----------------------------------------------------------------- // load() is called when the user loads a scene file where this // script was active. the LScript engine will automatically reload // and recompile this script in such a case. in load(), we need to // read in our save()'d operating parameters. load: what, // either SCENEMODE (ASCII) or OBJECTMODE (binary) io // a pseudo-FileObject that only supports a subset of the // full FileObject methods { } //----------------------------------------------------------------- // save() is activated when the user saves a scene file where this // script is active. in save(), we need to store our operating // parameters into the scene file. save: what, io { }