using transition.to with blur filter

Hi all, 

The answer is probably right in front of me but I am racking my brain. 

I want to have the blur filter slowly applied to an image using transition.to().

In flash using Tweenlite, it would be something like this:

TweenLite.to(currentScreen, .5, {blurFilter:{blurX:15, blurY:15}});

It doesn’t look like the blur filter in Corona SDK has any parameters, only gaussian blur. It is either on/off. In which case, how would you use transition.to() with the gaussian blur parameters?

Thanks!

Perry

I tried initially setting up the gaussian blur with min settings in createScene:

[lua]

image0.fill.effect = “filter.blurGaussian”

image0.fill.effect.horizontal.blurSize = 2

image0.fill.effect.horizontal.sigma = 2

image0.fill.effect.vertical.blurSize = 2

image0.fill.effect.vertical.sigma = 2

[/lua]

Then in enterScene, I try this with horrible errors :slight_smile:

[lua]

transition.to( image0.fill.effect, { time=500, horizontal.blurSize=20, horizontal.sigma=140, vertical.blurSize=20, vertical.sigma=140 } )

[/lua]

That seemed to be how the sepia filter works with transition.to() on the filter docs page…

Hi @visualstation,

This seems to be the correct notation… what errors are you getting? Or is it a performance issue? Gaussian blurs in general tend to be performance hogs in a transition/movement kind of situation.

Brent

Brent,

I’m not at work at the moment, but from what I recall, the error seems to be with the transition.to( ) code. It is expecting a “}” near the “=” sign. The code in the createScene works fine. 

I could just fade in a pre-blurred image over top of the original, but that would defeat the graphics 2.0 goodness :slight_smile:

Thanks!

Perry

I don’t get an error when I do this:

[lua]

transition.to( image0.fill.effect, { time=500, blurSize=20, sigma=140, blurSize=20, sigma=140 } )

[/lua]

But nothing also happens with that code either. 

I tried fading in the image with the sepia filter and it works ok. There is something about transitioning all the gaussian blur parameters in the transition.to() code. 

Perry

Hi @visualstation,

I just realized, the transition doesn’t let you specify sub-parameters in the table section, so you’ll need to perform two consecutive transitions for the blurGaussian effect, one for “.horizontal” and another for “.vertical”. Sorry for the inconvenience, it seems this is how the engineers structured it.

[lua]

transition.to( object.fill.effect.horizontal, { time=2000, blurSize=100 } )

transition.to( object.fill.effect.vertical, { time=2000, blurSize=100 } )

[/lua]

Best regards,

Brent

Ooh, this works!

Trying it out, I had to do 4 transitions though (2 for blur size, and 2 for sigma) to see some results:

[lua]

transition.to( image0.fill.effect.horizontal, { time=250, blurSize=25 } )

transition.to( image0.fill.effect.horizontal, { time=250, sigma=140 } )

transition.to( image0.fill.effect.vertical, { time=250, blurSize=25 } )

transition.to( image0.fill.effect.vertical, { time=250, sigma=140 } )

[/lua]

This is what I was trying to accomplish, thank you!!

Perry

Hi Perry,

What is the size of your image and did you tested this transition on iPad2? If yes then did you notice any lag or un-smooth transition on iPad2?

thanks

Kyle

Kyle,

I was probably pushing the limits with my example, but maybe this can give you a general idea as a baseline. I was trying to blur out a full-screen background image (2048 x 1536). When the background blurs out, an overlay slides over top. 

So far, I have only had a chance to test on an iPad mini retina. At 30fps there was a tiny bit of lag on the blur. At 60fps, it was smoother but didn’t feel like it was all the way there in terms of smoothness. Doing 4 transitions at once with the blur filter must be pretty intensive, especially on an image that takes up the whole screen. 

I would imagine with the iPad 2, you may want to stick with 30fps. I’m just guessing, but there might be a slight lag, if blurring a full-screen image. I am planning to borrow an iPad 2 soon to test this out. On the iPad 2 though, the image would only be 1024 x 768, so maybe performance would be better?

Hope this helps!

Perry

Thanks a lot! It’s really a great help to me.

Kyle  

Hey visualstation,

This isn’t specifically relevant to the transition question, but, perhaps helpful in general.

I’ve written some code to use most of the filters in my app on a user taken photo, and have a utility module that at the very least provides a data definition that can be used to work with the filters (via a UI) in an app. In my app I let the user manipulate slider bars, so there’s a couple functions in here to convert filter values to slider bar values (percent) as well. Anyways, just something I cobbled together that might provide some ideas / a base of filter data values to work with.  Don’t intend to make it truly generic, or support it, or anything else… It’s “Popeye” code: it is what it is. Hopefully there’s something helpful.

Best wishes.

[/lua]


–  filterutils.lua

– localNet filter definitions and helper functions

module(…, package.seeall)

mojoData = require(“mojodata”)  – app global data module, where user edited filter data will be stored (as they change filter values, app will remember last settings)

utils = require(“utils”)    – Some misc. App utility functions


– FILTER DICTIONARY… Default values / ranges for filters (including some UI info per filter)

filterDefs = {}

filterDefs[#filterDefs+1] = {  
  effect = “brightness”,
  title = “Brightness”, --UI name
  isEditable = true,
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  audioFile = 1,
  params = {
    “intensity”,
  },
  defaults = {
    { min = 0.0, max = 0.7, default = 0.2 },
–    { min = 0, max = 1, default = 0.5 },
  }
}

filterDefs[#filterDefs+1] = {   
  effect = “contrast”,
  title = “Contrast”, --UI name
  isEditable = true,
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  audioFile = 1,
  params = {
    “contrast”,
  },
  defaults = {
    { min = 0.1, max = 4, default = 2 },
  }
}

filterDefs[#filterDefs+1] = {      – ok to use
  effect = “saturate”,
  title = “Saturate”, --UI name
  isEditable = true,
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  audioFile = 1,
  params = {
    “intensity”,
  },
  defaults = {
    { min = 0.0, max = 8, default = 4.0 },
  }
}

filterDefs[#filterDefs+1] = { – dont bother
  effect = “hue”,
  title = “Hue”, --UI name
  isEditable = true,
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  audioFile = 1,
  params = {
    “angle”,
  },
  defaults = {
    { min = 0, max = 360, default = 180 },
  }
}

filterDefs[#filterDefs+1] = {     – looks good
  effect = “vignette”,
  title = “Vignette”, --UI name
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  isEditable = true,
  audioFile = 1,
  params = {
    “radius”,
  },
  defaults = {
    { min = 0, max = 1, default = 0.1 },
  }
}

filterDefs[#filterDefs+1] = {  – looks good
  effect = “grayscale”,
  title = “Grayscale”, --UI name
  isEditable = false,
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  audioFile = 1,
  params = {},
  defaults = {}
}

filterDefs[#filterDefs+1] = {    – looks good
  effect = “sepia”,
  title = “Sepia”, --UI name
  isEditable = true,
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  audioFile = 1,
params = {
    “intensity”,
  },
  defaults = {
    { min = 0, max = 1, default = 0.95 },
  }
}

filterDefs[#filterDefs+1] = {  – works good
  effect = “emboss”,
  title = “Emboss”, --UI name
  isEditable = true,  
  thumbDistorts = true,    – some effects, thumbnail looks dif than large size…
  audioFile = 2,
  params = {
    “intensity”,
  },
  defaults = {
    { min = 0, max = 4, default = 1 },
  }
}

filterDefs[#filterDefs+1] = {  – looks ok, a lkittle funky, but not bad
  effect = “posterize”,
  title = “Posterize”, --UI name
  isEditable = true,
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  audioFile = 3,
  params = {
    “colorsPerChannel”,
  },
  defaults = {
–    { min = 2, max = -1, default = 4 },
    { min = 2, max = 15, default = 3 },
  }
}

filterDefs[#filterDefs+1] = {       – looks good
  effect = “colorChannelOffset”,
  title = “Color Offset”, --UI name
  isEditable = true,
  thumbDistorts = true,    – some effects, thumbnail looks dif than large size…   
  audioFile = 3,
  params = {
    “yTexels”,
    “xTexels”,
  },
  defaults = {
    { min = 0, max = 100, default = 50 },     – was -1
    { min = 0, max = 100, default = 50 },     – was -1
  }
}

filterDefs[#filterDefs+1] = {
  effect = “bloom”,
  title = “Bloom”, --UI name
  isEditable = false,
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  audioFile = 1,
  params = {
  },
  defaults = {
  }
}

filterDefs[#filterDefs+1] = {  – looks ok, funky
  effect = “invert”,
  title = “Invert”, --UI name
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  audioFile = 3,
  params = {},
  isEditable = false,
  defaults = {}
}

filterDefs[#filterDefs+1] = {  – works good
  effect = “levels”,
  title = “Levels”, --UI name
  isEditable = true,
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  audioFile = 2,
params = {
    “gamma”,
    “white”,
    “black”,
  },
  defaults = {
    { min = 1, max = 20, default = 1.06 },
    { min = 0, max = 10, default = 0.9 }, – 200
    { min = 0, max = 10, default = 0.1 },  – 100
    
–    { min = 0, max = 1, default = 1.06 },
–    { min = 0, max = 255, default = 215/255 },
–    { min = 0, max = 255, default = 144/255 },
  }
}

filterDefs[#filterDefs+1] = {  – looks 50’s ish
  effect = “monotone”,
  title = “Monotone”, --UI name
  isEditable = false,
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  audioFile = 1,
  params = {
    “r”,
    “g”,
    “b”,
    “a”,
  },
  defaults = {
    { min = 0, max = 1, default = 0.4 },
    { min = 0, max = 1, default = 0.4 },
    { min = 0, max = 1, default = 0.4 },
    { min = 0, max = 1, default = 1 },
  }
}

filterDefs[#filterDefs+1] = {  – cool
  effect = “pixelate”,
  title = “Pixelate”, --UI name
  isEditable = true,
  thumbDistorts = true,    – some effects, thumbnail looks dif than large size…
  audioFile = 2,
  params = {
    “numPixels”,
  },
  defaults = {
–    { min = 0, max = -1, default = 4 },
    { min = 8, max = 80, default = 16 },
  }
}

filterDefs[#filterDefs+1] = {   – works, but not so great
  effect = “bulge”,
  title = “Bulge”, --UI name
  isEditable = true,
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  audioFile = 3,
  params = {
    “intensity”,
  },
  defaults = {
    { min = 0.1, max = 2.5, default = 1.7 },
  }
}

filterDefs[#filterDefs+1] = {   – ok, funky, but ok
  effect = “sobel”,
  title = “Sobel”, --UI name
  isEditable = false,
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  audioFile = 3,
  params = {},
  defaults = {}
}

filterDefs[#filterDefs+1] = {      – looks good
  effect = “swirl”,
  title = “Swirl”, --UI name
  isEditable = true,
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  audioFile = 3,
 params = {
    “intensity”,
  },
  defaults = {
    { min = 0, max = 2, default = 1.0 },
  }
}

filterDefs[#filterDefs+1] = {   – weird, probably dont use
  effect = “straighten”,
  title = “Rotate”, --UI name
  isEditable = true,
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  audioFile = 2,
  params = {
    “angle”,
    “width”,
    “height”,
  },
  defaults = {
    { min = 0, max = 360, default = 45 },
    { min = 1, max = -1, default = 1 },
    { min = 1, max = -1, default = 1 },
  }
}

filterDefs[#filterDefs+1] = {  – works good
  effect = “desaturate”,
  title = “Desaturate”, --UI name
  isEditable = true,
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  audioFile = 1,
 params = {
    “intensity”,
  },
  defaults = {
    { min = 0, max = 1, default = 0.35 },
  }
}

filterDefs[#filterDefs+1] = {  – cool, like the frostedglass
  effect = “opTile”,
  title = “OpTile”, --UI name
  isEditable = true,
  thumbDistorts = true,    – some effects, thumbnail looks dif than large size…
  audioFile = 2,
  params = {
    “numPixels”,
    “scale”,
    “angle”,
  },
  defaults = {
    { min = 30, max = 160, default = 40 },
    { min = 0, max = 50, default = 2.8 },   – was -1
    { min = 0, max = 360, default = 0 },
  }
}

filterDefs[#filterDefs+1] = {  – looks good, no t supported older droids tho
  effect = “zoomBlur”,
  title = “Zoom Blur”, --UI name
  isEditable = true,
  thumbDistorts = true,    – some effects, thumbnail looks dif than large size…
  audioFile = 3,
  params = {
    “intensity”,
    “u”,
    “v”,
  },
  defaults = {
    { min = 0.2, max = 4, default = 1.0 },
    { min = 0, max = 1, default = 0.5 },
    { min = 0, max = 1, default = 0.5 },
  }
}

filterDefs[#filterDefs+1] = {  – touchy, dont bother
  effect = “exposure”,
  title = “Exposure”, --UI name
  isEditable = true,
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  audioFile = 2,
  params = {
    “exposure”,
  },
  defaults = {
    { min = -3, max = 3, default = 1 },
  }
}

filterDefs[#filterDefs+1] = {   – looks good, not older devices
  effect = “scatter”,
  title = “Scatter”, --UI name
  isEditable = true,
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  audioFile = 3,
  params = {
    “intensity”,
  },
  defaults = {
    { min = 0, max = 1, default = 0.5 },
  }
}

filterDefs[#filterDefs+1] = {      – is ok, not older devices
  effect = “sharpenLuminance”,
  title = “Sharpen Lum”, --UI name
  isEditable = true,
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  audioFile = 1,
  params = {
    “sharpness”,
  },
  defaults = {
    { min = 0, max = 1, default = 0.4 },
  }
}

filterDefs[#filterDefs+1] = {
  effect = “woodCut”,
  title = “WoodCut”, --UI name
  thumbDistorts = true,    – some effects, thumbnail looks dif than large size…
  isEditable = true,
  audioFile = 2,
  params = {
    “intensity”,
  },
  defaults = {
    { min = 0, max = 1, default = 0.5 },
  }
}

filterDefs[#filterDefs+1] = {  – boring?
  effect = “median”,
  isEditable = false,
  title = “Median”, --UI name
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  audioFile = 1,
  params = {},
  defaults = {}
}


– unused filters

–[[

filterDefs[#filterDefs+1] = {  – dynamic effect
  effect = “iris”,
  title = “Iris”, --UI name
  isEditable = true,
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  audioFile = 1,
  params = {
    “aperture”,
    “center”,
    “aspectRatio”,
    “smoothness”,
  },
  defaults = {
    { min = 0, max = 1, default = 0 },
    { min = { 0, 0 }, max = { 1, 1 }, default = { .5, .5 } },
    { min = 0, max = -1, default = 1 },
    { min = 0, max = 1, default = 0 },
  }
}

filterDefs[#filterDefs+1] = {   – no good, doesnt work…
  effect = “crosshatch”,
  title = “Crosshatch”, --UI name
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  audioFile = 1,
  params = {
    “grain”,
  },
  defaults = {
    { min = 0, max = 1, default = 0 },
  }
}

filterDefs[#filterDefs+1] = {  – ok, but kinda ugly
  effect = “duotone”,
  title = “Duotone”, --UI name
  isEditable = false,
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  audioFile = 1,
  params = {
    “darkColor”,
    “lightColor”,
  },
  defaults = {
    { min = {0,0,0,0}, max = {1,1,1,1}, default = {0,0,0.5,1} },
    { min = {0,0,0,0}, max = {1,1,1,1}, default = {1,0,0,1} },
  }
}

filterDefs[#filterDefs+1] = { – ? didnt work first pass?
  effect = “chromaKey”,
  title = “ChromaKey”, --UI name
  isEditable = true,
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  audioFile = 1,
  params = {
    “sensitivity”,
    “smoothing”,
    “color”,
  },
  defaults = {
    { min = 0, max = 1, default = 0.4 },
    { min = 0, max = 1, default = 0.1 },
    { min = {0,0,0,0}, max = {1,1,1,1}, default = {1,1,1,1} },
  }
}

filterDefs[#filterDefs+1] = {      – dynamic, dont use
  effect = “crystallize”,
  title = “Crystallize”, --UI name
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  audioFile = 1,
  params = {
    “numTiles”,
  },
  defaults = {
    { min = 2, max = 256, default = 16 },
  }

filterDefs[#filterDefs+1] = {  – not bad, not older devices though
  effect = “polkaDots”,
  title = “Polka Dots”, --UI name
  isEditable = true,
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  audioFile = 1,
  params = {
    “numPixels”,
    “dotRadius”,
  },
  defaults = {
    { min = 4, max = 50, default = 6 },
    { min = 0, max = 1, default = 1 },
  }
}

filterDefs[#filterDefs+1] = {  – probably best lookin blur
  effect = “blurGaussian”,
  title = “Gaussian Blur”, --UI name
  isEditable = false,
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  params = {
    “horizontal.blurSize”,
    “horizontal.sigma”,
    “vertical.blurSize”,
    “vertical.sigma”,
  },
  defaults = {
    { min = 1, max = 20, default = 20 },  – 4
    { min = 0, max = 1, default = 1 }, – 1
    { min = 1, max = 20, default = 20 },
    { min = 0, max = 1, default = 1 },
  }
}

filterDefs[#filterDefs+1] = {   – dont bother
  effect = “blur”,
  title = “Blur”, --UI name
  isEditable = false,
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  params = {},
  defaults = {}
}

filterDefs[#filterDefs+1] = {  – looks good – not supported older devices
  effect = “frostedGlass”,
  isEditable = true,
  title = “Frosted Glass”, --UI name
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  params = {
    “scale”,
  },
  defaults = {
    { min = 1, max = 100, default = 5 },
  }
}

filterDefs[#filterDefs+1] = {   – dont bother
  effect = “blurHorizontal”,
  title = “H Blur”, --UI name
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  params = {
    “horizontal.blurSize”,
    “horizontal.sigma”,
  },
  defaults = {
    { min = 0, max = 255, default = 1 },
    { min = 0, max = 1, default = 1 },
  }
}

filterDefs[#filterDefs+1] = {   – dont bother
  effect = “blurVertical”,
  title = “V Blur”, --UI name
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  params = {
    “vertical.blurSize”,
    “vertical.sigma”,
  },
  defaults = {
    { min = 0, max = 100, default = 1 },
    { min = 0, max = 1, default = 1 },
  }
}

filterDefs[#filterDefs+1] = {      – dont bother, dynamic effect
  effect = “dissolve”,
  title = “Dissolve”, --UI name
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  params = {
    “threshold”,
  },
  defaults = {
    { min = 0, max = 1, default = 0.5 },
  }
}

filterDefs[#filterDefs+1] = {   – crashed app? dynamic?
  effect = “linearGradient”,
  title = “Linear Gradient”, --UI name
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  params = {
    “color1”,
    “position1”,
    “color2”,
    “position2”,
  },
  defaults = {
    { min = {0,0,0,0}, max = {1,1,1,1}, default = {1,0,0,1} },
    { min = {0,0}, max = {1,1}, default = {0,0} },
    { min = {0,0,0,0}, max = {1,1,1,1}, default = {0,0,1,1} },
    { min = {0,0}, max = {1,1}, default = {1,1} },
  }
}

filterDefs[#filterDefs+1] = {  – dynamic?
  effect = “linearWipe”,
  title = “Linear Wipe”, --UI name
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  params = {
    “direction”,
    “smoothness”,
    “progress”,
  },
  defaults = {
    { min = {0,0}, max = {1,1}, default = {1,0} },
    { min = 0, max = 1, default = 0 },
    { min = 0, max = 1, default = 0 },
  }
}

filterDefs[#filterDefs+1] = {          – Not good for use in photo - is better for dynamic effects
  effect = “radialWipe”,
  title = “Radial Wipe”, --UI name
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  params = {
    “canter”,
    “progress”,
    “axisOrientation”,
    “smoothness”,
  },
  defaults = {
    { min = {0,0}, max = {1,1}, default = {.5,.5} },
    { min = 0, max = 1, default = 0.5 },
    { min = 0, max = 1, default = 0.33 },
    { min = 0, max = 1, default = 0.5 },
–    { min = 0, max = 1, default = 0 },
–    { min = 0, max = 1, default = 0 },
–    { min = 0, max = 1, default = 0 },    
  }
}

filterDefs[#filterDefs+1] = {   – dynamic, dont use
  effect = “wobble”,
  title = “Wobble”, --UI name
  thumbDistorts = false,    – some effects, thumbnail looks dif than large size…
  params = {
    “amplitude”,
  },
  defaults = {
    { min = 0, max = -1, default = 10 },
  }
}

filterDefs[#filterDefs+1] = {  – doesn’t work?
  effect = “colorMatrix”,
  isEditable = false,
  title = “Color Matrix”, --UI name
  thumbDistorts = true,    – some effects, thumbnail looks dif than large size…
  audioFile = 2,
  params = {
    “coefficients”,
    “bias”
  },
    defaults = {
        { default = {1.0, 0.0, 0.0, 0.0,  0.0, 1.0, 0.0, 0.0,  0.0, 0.0, 1.0, 0.0,  0.0, 0.0, 0.0, 1.0 }},
        { default = { 0.0, 0.0, 0.0, 0.0 }, min = { -1.0, -1.0, -1.0, -1.0 }, max = { 1.0, 1.0, 1.0, 1.0 }}
    }
}    

filterDefs[#filterDefs+1] = {  – doesn’t work?
  effect = “colorPolynomial”,
  isEditable = false,
  title = “Color Polynomial”, --UI name
  thumbDistorts = true,    – some effects, thumbnail looks dif than large size…
  audioFile = 2,
  params = {
    “coefficients”,
  },
  defaults = {
    {default = { 1.0, 0.0, 0.0, 0.0,  0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0,  0.0, 0.0, 0.0, 1.0 } }
  }
}

–]]

function applyFilter( image, index )

print(" – applyFilter()")
print("  - index, numFilters == ", index, #filterDefs)

    – Lets check / load the default data into saved global data, if it’s not there…

    – NOTE: app stores last user filter settings in a global array (mojodata.filterDefs), which is saved to device after edits…
    if( mojoData.filterDefs == nil ) then        – Has initial filter defs been saved to permanent array yet?
        print(" – adding default filters defs")
        mojoData.filterDefs = filterDefs          – Use the default filterDefs above…
–        utils.saveTable(mojoData.filterDefs, “filterDefs.opt”) – saved later by calling code, not saved here anymore
    else
        print(" – using existing filters defs")    – Already been loaded
    end
    
    if( index == 0 ) then     – 0 means to clear out any filter on the passed object    
        image.fill.effect = “”  – reset to none
    else        
      local info = mojoData.filterDefs[index] – filterDefs[index]  – ok, lets point at the filter definition…
      
      local p = info.params
      local d = info.defaults
      
      image.fill.effect = “filter.” … info.effect  – Apply the little bugger
      
      print("  - setting effect - “, info.effect)
      
      print(” – btw, audio == ", mojoData.filterDefs[index].audioFile )
      
      for i=1, #p do
        local parameter = p[i]
–        utils.printTable(p,“FILTER”,3)
–        local m0, m1, d = d[i].min, d[i].max, d[i].default
        local m0 = d[i].min
        local m1 = d[i].max        
        local val = d[i].default

    --[[          
        if ( type(m0) == “number” and type(m1) == “number” ) then
          
          --numeric
          if ( m0 == 0 and m1 == 1 ) then
            val = mRan()
          elseif( m1 == -1 ) then
            val = mRan() * 100
          elseif( m0 == -10 and m1 == 10 ) then
            --special case EXPOSURE
            local v = 1
            if ( mRan() * 100 < 20 ) then
              v = -1
            end
            val = mRan() * ( 5 * v )
          else
            
            --special case
            if ( “levels” == info.effect ) then
              val = ( mRan() * m1 ) / 255
            else
              local h = mRan() * m1
              val = math.max( m0, h )         
            end
          end
        elseif ( type(m0) == “table” and type(m1) == “table” ) then
          
          if ( #m0 == 2 and #m1 == 2 ) then
            val = { mRan(), mRan() }
          else
            val = color( mRan(1, 255), mRan(1, 255), mRan(1, 255) )    
          end
        end
    --]]
–    val =
        print(" – parm, val == “, parameter, val)
–        print(”  - a - “, image.fill.effect[parameter])
        image.fill.effect[parameter] = val
        print(”    …set.")
        end    
    end   

end

function getPercent(index) – returns % setting of 1st param of effect
    local val
    
    val = mojoData.filterDefs[index].defaults[1].max - mojoData.filterDefs[index].defaults[1].min
    print(" – val1 == “, val)
    val = ((mojoData.filterDefs[index].defaults[1].default + math.abs(mojoData.filterDefs[index].defaults[1].min))/val) * 100
    
    print(” ---- calc’d percent as ", val)
    return val

end

function setPercent(index, per) – returns % setting of 1st param of effect

    local val
    
    val = mojoData.filterDefs[index].defaults[1].max - mojoData.filterDefs[index].defaults[1].min
    val = mojoData.filterDefs[index].defaults[1].min + (val * per * .01)   – Account for the %
    
    print(" ---- calc’d saved val as", val)    
    mojoData.filterDefs[index].defaults[1].default = val
    
    return val

end

[lua]

mpappas,

Thank you for taking the time to post the code above. I am still learning about the various filters, so it was interesting to read through your comments about each filter to see which ones work better in different situations (ie. some seem to be dynamic). 

Perry

I tried initially setting up the gaussian blur with min settings in createScene:

[lua]

image0.fill.effect = “filter.blurGaussian”

image0.fill.effect.horizontal.blurSize = 2

image0.fill.effect.horizontal.sigma = 2

image0.fill.effect.vertical.blurSize = 2

image0.fill.effect.vertical.sigma = 2

[/lua]

Then in enterScene, I try this with horrible errors :slight_smile:

[lua]

transition.to( image0.fill.effect, { time=500, horizontal.blurSize=20, horizontal.sigma=140, vertical.blurSize=20, vertical.sigma=140 } )

[/lua]

That seemed to be how the sepia filter works with transition.to() on the filter docs page…

Hi @visualstation,

This seems to be the correct notation… what errors are you getting? Or is it a performance issue? Gaussian blurs in general tend to be performance hogs in a transition/movement kind of situation.

Brent

Brent,

I’m not at work at the moment, but from what I recall, the error seems to be with the transition.to( ) code. It is expecting a “}” near the “=” sign. The code in the createScene works fine. 

I could just fade in a pre-blurred image over top of the original, but that would defeat the graphics 2.0 goodness :slight_smile:

Thanks!

Perry

I don’t get an error when I do this:

[lua]

transition.to( image0.fill.effect, { time=500, blurSize=20, sigma=140, blurSize=20, sigma=140 } )

[/lua]

But nothing also happens with that code either. 

I tried fading in the image with the sepia filter and it works ok. There is something about transitioning all the gaussian blur parameters in the transition.to() code. 

Perry

Hi @visualstation,

I just realized, the transition doesn’t let you specify sub-parameters in the table section, so you’ll need to perform two consecutive transitions for the blurGaussian effect, one for “.horizontal” and another for “.vertical”. Sorry for the inconvenience, it seems this is how the engineers structured it.

[lua]

transition.to( object.fill.effect.horizontal, { time=2000, blurSize=100 } )

transition.to( object.fill.effect.vertical, { time=2000, blurSize=100 } )

[/lua]

Best regards,

Brent

Ooh, this works!

Trying it out, I had to do 4 transitions though (2 for blur size, and 2 for sigma) to see some results:

[lua]

transition.to( image0.fill.effect.horizontal, { time=250, blurSize=25 } )

transition.to( image0.fill.effect.horizontal, { time=250, sigma=140 } )

transition.to( image0.fill.effect.vertical, { time=250, blurSize=25 } )

transition.to( image0.fill.effect.vertical, { time=250, sigma=140 } )

[/lua]

This is what I was trying to accomplish, thank you!!

Perry

Hi Perry,

What is the size of your image and did you tested this transition on iPad2? If yes then did you notice any lag or un-smooth transition on iPad2?

thanks

Kyle

Kyle,

I was probably pushing the limits with my example, but maybe this can give you a general idea as a baseline. I was trying to blur out a full-screen background image (2048 x 1536). When the background blurs out, an overlay slides over top. 

So far, I have only had a chance to test on an iPad mini retina. At 30fps there was a tiny bit of lag on the blur. At 60fps, it was smoother but didn’t feel like it was all the way there in terms of smoothness. Doing 4 transitions at once with the blur filter must be pretty intensive, especially on an image that takes up the whole screen. 

I would imagine with the iPad 2, you may want to stick with 30fps. I’m just guessing, but there might be a slight lag, if blurring a full-screen image. I am planning to borrow an iPad 2 soon to test this out. On the iPad 2 though, the image would only be 1024 x 768, so maybe performance would be better?

Hope this helps!

Perry