filter effects appear different on images from sprite sheet vs individual files

I’m trying to use the wobble effect animation (similar to the Sample Code animation effect in the Filter Demo) on some letter images.  If I load the newImageRect with an individual png file, the wobble effect works fine.  However, if I load the newImageRect using a sprite sheet containing all the letters, it looks like the effect is being applied to the entire sprite sheet png instead of just the single image frame that I want.  So the wobble effect is barely noticeable.  The issue becomes really noticeable when using the “bulge” effect on an image from a sprite sheet as the other images next to your target image frame become visible.

Is this a known issue and is there a solution?

Thanks!

Kenric

Hi @Kenric,

Can you please post your basic code for this so we may inspect it?

Thanks,

Brent

Hi Brent,

Thanks for the fast reply.  You can easily test this by modifying the main.lua in the FilterDemo sample app to use a sprite sheet in the newImageRect call.  I’ve included my changes to that file and the test sprite sheet data I used.  In this example, you’ll notice that the wobble effect for the H is less pronounced than when you use the individual png file.  The most obvious example is the spiral effect which shows the other letters around the H.

[lua]

– Some effects are time based (e.g. random),

– so force Corona to re-blit them.

display.setDrawMode( “forceRender” )

local sheetInfo = require(“test”)

local imageSheet = graphics.newImageSheet( “test.png”, sheetInfo:getSheet() )

local numImages = 0

for j=1,3 do

    for i=1,3 do

        numImages = numImages + 1

        --local image = display.newImageRect( “sample320x480.jpg”, w, h )

        --local image = display.newImageRect( “letter_cap_h.png”, 49, 80 )

        local image = display.newImageRect(imageSheet, sheetInfo.frameIndex[“letter_cap_h”], 49, 80)

        group:insert( image )

        image:translate( x + w*(i-1), y + h*(j-1) )

        local filter = effects[numImages]

        image.fill.effect = filter.name

        setEffect( image.fill.effect, filter, 1 )

    end

end

[/lua]

Hi @kleung,

Can you submit this same project into an official bug report?

http://developer.coronalabs.com/content/bug-submission

Thanks,

Brent

Follow-up… I notice your test project doesn’t work “out of the box” because it doesn’t have a main.lua file, and it throws an error. It’s probably easily fixable, but please submit a complete working project to the bug report system.

Thanks,

Brent

I’ve submitted the bug report and included my main.lua along with the other test files.  Thanks.

Hi @Kenric,

Can you please post your basic code for this so we may inspect it?

Thanks,

Brent

Hi Brent,

Thanks for the fast reply.  You can easily test this by modifying the main.lua in the FilterDemo sample app to use a sprite sheet in the newImageRect call.  I’ve included my changes to that file and the test sprite sheet data I used.  In this example, you’ll notice that the wobble effect for the H is less pronounced than when you use the individual png file.  The most obvious example is the spiral effect which shows the other letters around the H.

[lua]

– Some effects are time based (e.g. random),

– so force Corona to re-blit them.

display.setDrawMode( “forceRender” )

local sheetInfo = require(“test”)

local imageSheet = graphics.newImageSheet( “test.png”, sheetInfo:getSheet() )

local numImages = 0

for j=1,3 do

    for i=1,3 do

        numImages = numImages + 1

        --local image = display.newImageRect( “sample320x480.jpg”, w, h )

        --local image = display.newImageRect( “letter_cap_h.png”, 49, 80 )

        local image = display.newImageRect(imageSheet, sheetInfo.frameIndex[“letter_cap_h”], 49, 80)

        group:insert( image )

        image:translate( x + w*(i-1), y + h*(j-1) )

        local filter = effects[numImages]

        image.fill.effect = filter.name

        setEffect( image.fill.effect, filter, 1 )

    end

end

[/lua]

Hi @kleung,

Can you submit this same project into an official bug report?

http://developer.coronalabs.com/content/bug-submission

Thanks,

Brent

Follow-up… I notice your test project doesn’t work “out of the box” because it doesn’t have a main.lua file, and it throws an error. It’s probably easily fixable, but please submit a complete working project to the bug report system.

Thanks,

Brent

I’ve submitted the bug report and included my main.lua along with the other test files.  Thanks.

Was there ever a resolution of this? Looks like distortion filters still don’t work sprite sheets, but maybe there’s some other solution?

Thanks

Here was the response on the bug report:

"Our engineer looked at this and determine that shaders apply to the texture and not the individual images within the texture. The only way you can make this work is to use individual textures and not an image sheet. The other way is apply the shader to a snapshot generated from the texture’s image.

We have this on our list to look at in the future but currently there is no fix for the way you have it coded now."

Was there ever a resolution of this? Looks like distortion filters still don’t work sprite sheets, but maybe there’s some other solution?

Thanks

Here was the response on the bug report:

"Our engineer looked at this and determine that shaders apply to the texture and not the individual images within the texture. The only way you can make this work is to use individual textures and not an image sheet. The other way is apply the shader to a snapshot generated from the texture’s image.

We have this on our list to look at in the future but currently there is no fix for the way you have it coded now."