21
Aug
08

Iterative CIFilter

Just discovered it’s possible to apply an effect iteratively in a CIKernel, by editing the JavaScript filter function. I’m going to have some fun with iterative glitching effects, I think!

This code simply applies a color addition on each pass, so if you feed in a black image, and set Color to a dark grey, the color of the output image get pregressively lighter as you turn up the number of Iterations.

Kernel Code:

kernel vec4 additionEffect(sampler image, __color Color)
{
	return sample(image, samplerCoord(image)) + Color;
}

JavaScript from bottom panel (with ‘Edit Filter Function’ option turned on):
function __image main(__image image, __color Color, __index Iterations) {

var result = additionEffect.apply(image.definition, null, image, Color);

for(i = 0; i < Iterations; i++) { result = additionEffect.apply(result.definition, null, result, Color); } return result; }[/code] You could iteratively apply some kind of distortion effect, using different values for each pass using the same method. You could even use the JS Math.random() function to to randomise the values being sent to each iteration of you CIKernel function, for added glitchy fun. Sadly I don't have time to play with this at the moment, but I can see some cool implementations, including maybe the possibility of doing something like this in a single CIFilter.

Advertisements

6 Responses to “Iterative CIFilter”


  1. August 21, 2008 at 4:56 pm

    *adds learning JavaScript to list of things to do*

  2. August 22, 2008 at 1:53 am

    Yeah, this is interesting, but I found it slow.

    You can also call other CIKernels/Image Units installed in the system using this setup. So you can do one pass, call a crop, then pass it back to your main CIKernel sampler, do something else with it, then spit it out.

    The javascript wrapper is how you do multipass with CIKL, but, I dunno, I did some experiments and found it a pain in the ass, and a bit slow. I mocked up my Lomo effect using it, and got poor framerates, but, it could have just been what I was doing.

    Id love to see the results of you experiments.

  3. 3 toneburst
    August 22, 2008 at 9:07 am

    Hi vade,

    I’ve done multipass stuff with CIKernel JavaScript code before, but just never thought about calling the kernel code from inside a loop before.

    In my experience, things get a bit confusing when you start changing the size of stuff in a CIKernel though (ie applying a crop). Despite several people trying to explain the DoD/ROI stuff to me, I never really got my head around it, to be honest.

    I’d be really interested to know if it’s possible to maintain an image between frames just using the JS wrapper code. Then you could do all kinds of interesting stuff with feedback. I have a feeling it’s not possible however. I know you can do this kind of thing in other ways.

    I’ve also just discovered another annoying limitation: you can’t feed structures into the JS part of a CIKernel, which is a bit annoying. You can use Bools and Indexes though, which is handy.

  4. 4 toneburst
    August 22, 2008 at 9:10 am

    Hi Rob,

    JS is a handy thing to know. I find it mainly useful in QC for creating and processing control signals. I also use it to package together lots of variables so I don’t have to do so much patching later on.

    You can often do things with a few lines of JS that it would take a lot of QC patches and loads of complicated wiring to do otherwise.

    a|x

  5. August 22, 2008 at 4:17 pm

    I *think* for feed back, you HAVE to use a CIAccumullator image unit.

    You MAY be able to get around this, by treating the JS function how youd patch it in QC. So, for feedback in QC, you typically have an accumulators input hooked to a processes output, and the output of the accumulator hooked into its input.

    So youd instantiate a CIAccumulator in the JS filter function, and use just like in QC? Id be curious to try, but there is sooo much to do! 🙂

  6. 6 toneburst
    August 22, 2008 at 5:56 pm

    I don’t think you can instantiate CIImageAccumulator from the JS code in a CIFilter, unfortunately (unless, as is quite likely, I’m missing something).

    You can instantiate filters using
    blah = Filter.theFilter(params);
    but I don’t think CIImageAccumulator is strictly-speaking a filter.

    If I try
    accum = Filter.CIImageAccumulator(image.definition,null,image);
    I just get the error
    ‘CIImageAccumulator: no such filter’
    so I guess that’s a non-starter, sadly 😦

    a|x


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Twitter

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

August 2008
M T W T F S S
« Jul   Sep »
 123
45678910
11121314151617
18192021222324
25262728293031

Links

Blog Stats

  • 467,455 hits

%d bloggers like this: