Multi-pass filter clarification needed or bug?

After some serious debugging it seems that you cannot adjust a filter parameter in a multi-pass filter unless all are adjusted together.

The code:

[lua]

local function setUpFilter()

  local kernal = {}

  kernal.language = “glsl”

  kernal.category = “filter”

  kernal.name = “blurFx”

  kernal.graph = {}

  kernal.graph.nodes =

  {

    horizontal = { effect = “filter.blurHorizontal”, input1 = “paint1” },

    vertical = { effect = “filter.blurVertical”, input1=“horizontal” },

  }

  kernal.graph.output = “vertical”

  graphics.defineEffect( kernal )

  local photo = display.newImage( “photobig.jpg” )

  photo.x = display.contentCenterX

  photo.y = display.contentCenterY

  photo.fill.effect = “filter.blurFx”

  photo.fill.effect.horizontal.blurSize = 200

  photo.fill.effect.vertical.blurSize = 0

  --after brief delay, update the parameters

  local function onChangeParameter()

    photo.fill.effect.horizontal.blurSize = 0

    photo.fill.effect.vertical.blurSize = 0

  end

  timer.performWithDelay( 1000, onChangeParameter )

end

setUpFilter()

[/lua]

The code above works as one would expect. After a second delay, the horizontal blurSize is set to 0, and is visually updated.

Now, if you comment out the second line in the onChangeParameter method, the first line seems to no longer trigger an update on the parameter.

[lua]

  --after brief delay, update the parameters

  local function onChangeParameter()

    photo.fill.effect.horizontal.blurSize = 0

    --photo.fill.effect.vertical.blurSize = 0

  end

  timer.performWithDelay( 1000, onChangeParameter )

[/lua]

In the above example, the horizontal blurSize is never updated visually.  The results are the same when trying other filter combinations as well as different parameter values.

You can view a screencast here.

Is this the way this functionality is supposed to operate?  Or am I doing something incorrectly?

Best.

Build 2047 - Windows 8.1

If you comment out the horizontal.blurSize instead of the vertical, does that make a difference?

I’ve swapped the horizontal and vertical around.  That will visually output properly.  It kind of seems like it only will update the last value in the chain after the initial parameter settings. 

Works:

[lua]

  photo.fill.effect.vertical.blurSize = 200

  photo.fill.effect.horizontal.blurSize = 0

  --after brief delay, update the parameters

  local function onChangeParameter()

    --photo.fill.effect.horizontal.blurSize = 0

    photo.fill.effect.vertical.blurSize = 0

  end

  timer.performWithDelay( 1000, onChangeParameter )

[/lua]

Does not work.

[lua]

photo.fill.effect.vertical.blurSize = 0
photo.fill.effect.horizontal.blurSize = 200

–after brief delay, update the parameters
local function onChangeParameter()
photo.fill.effect.horizontal.blurSize = 0
–photo.fill.effect.vertical.blurSize = 0
end
timer.performWithDelay( 1000, onChangeParameter )[/lua]

Again, I have tried other combos ( scatter / hue ) and the result are the same. Anything else I can provide?

Best.

@develephant  Thanks for the post - we will look into the issue. The FilterGraphDemo doesn’t exhibit the issue because of the line: display.setDrawMode( “forceRender” ). This is a potential work-around for you for the moment.

@Bryan01 Thanks for the tip.  What does display.setDrawMode( “forceRender” ) do differently?

At a high level, it forces a redraw to happen every frame as opposed to only on an event like setting the blurSize, so it should be used sparingly for performance.

If you comment out the horizontal.blurSize instead of the vertical, does that make a difference?

I’ve swapped the horizontal and vertical around.  That will visually output properly.  It kind of seems like it only will update the last value in the chain after the initial parameter settings. 

Works:

[lua]

  photo.fill.effect.vertical.blurSize = 200

  photo.fill.effect.horizontal.blurSize = 0

  --after brief delay, update the parameters

  local function onChangeParameter()

    --photo.fill.effect.horizontal.blurSize = 0

    photo.fill.effect.vertical.blurSize = 0

  end

  timer.performWithDelay( 1000, onChangeParameter )

[/lua]

Does not work.

[lua]

photo.fill.effect.vertical.blurSize = 0
photo.fill.effect.horizontal.blurSize = 200

–after brief delay, update the parameters
local function onChangeParameter()
photo.fill.effect.horizontal.blurSize = 0
–photo.fill.effect.vertical.blurSize = 0
end
timer.performWithDelay( 1000, onChangeParameter )[/lua]

Again, I have tried other combos ( scatter / hue ) and the result are the same. Anything else I can provide?

Best.

@develephant  Thanks for the post - we will look into the issue. The FilterGraphDemo doesn’t exhibit the issue because of the line: display.setDrawMode( “forceRender” ). This is a potential work-around for you for the moment.

@Bryan01 Thanks for the tip.  What does display.setDrawMode( “forceRender” ) do differently?

At a high level, it forces a redraw to happen every frame as opposed to only on an event like setting the blurSize, so it should be used sparingly for performance.