RectPath Manipulation on Sprite Object Equals Strange Distortion / Pixelation on Device

When I manipulate a sprite object with RectPath the object gets pixelated/distorted. It works as expected in the simulator but not on device(iPad Air 2, iPhone 5 iOS, 10.1.1). The first frame of the sprite animation works perfectly also on device, but any subsequent frame gets distorted/pixelated when manipulated with RectPath. Tested this with daily builds 2017.3003 and 2017.3068 with Corona Viewer. 

My code is simply:

spriteObject.path.y2 = -20

As a workaround I just keep the first frame of the sprite and avoid running any animation while manipulating the object with RectPath. It’s limiting.

This sounds a lot like a problem I had a few months ago. While I don’t really work with sprite sheets much, I experienced a similar problem when I switched to “repeat” for tiling the background and didn’t return it to “clampToEdge” for my non-power-of-two display objects.  Everything worked fine in the simulator but distortions or omissions occurred on devices.

Have you changed the default texture wrapping with display.setDefault( ) from “clampToEdge” to “repeat” or “mirroredRepeat”?

If you are using any third party code or a plugin, changes to the default settings might have sneaked in.  That’s what happened to me.

Once I finished tiling the background I switched the defaults back to “clampToEdge” and all was fixed.

[lua]

display.setDefault( “textureWrapX”, “clampToEdge” ) 

display.setDefault( “textureWrapY”, "clampToEdge " )

[/lua]

Maybe something similar is happening in your case?

Thank you sharp100 for you suggestion. I tried all the texture wrapping modes but unfortunately it makes no difference. I see the same distortion/pixelation with all of them.  

It sounds like you are applying a distortion as path.y2 is the bottom left-hand corner of an object is this what you are trying to do?  More info

If you want to move it along a path then use a different method.

Yes I’m deliberately distorting the sprite object. It works as expected in simulator. The texture stretches but it still looks good. All frames of the animation sequences look good. On device all other frames except the 1st one, look terrible. Somehow pixelated and with jagged edges.

I can’t be the only one distorting sprite objects with RectPath. Also, It would be useful to know if someone is succesfully doing this without the mentioned pixelation on device. Anyone?

I solved a similar issue with fills by adjusting the xScale and yScale of the fill.

Maybe you could apply a scale to the sprite just before it distorts?  The result will still be strange buy maybe it could fix the pixelation.

[lua]

local newHeight = object.height - 20 – 20 was the value used in the example

object.yScale = newHeight / object.height – yScale as a percentage equal to the distortion

[/lua]

What size are the sprites?  Sometimes making the size of object and images equal to a power or 2 fixes problems like pixelation or blank images.  I’m not always sure why it worked but I have fixed graphic problems in the past by making the images size equal to a power or 2 and then scaling down.

I’m not sure what is the idea behind scaling the sprite first…To me, this looks like a serious bug. It works perfectly in the simulator and the first frame works also on device.

The size of sprite sheet is already power of two(1024x256), but the frame is not. 

Could be a bug for sure.  My thought about scaling was that if you scale the object it might force a recalculation of the graphics.

Hi @polygonblog,

Please file a simple bug report with mini-project showing this happening, so we can investigate on our side.

Thanks,

Brent

sharp100: I see your logic. I tested scaling but unfortunately it makes no difference. Thank you anyway!

Brent: Ok, I just filed a bug report with the name “RectPath Manipulation on Sprite Object Causes Strange Pixelation on Device”.

Hi @polygonblog,

Thanks! In the meantime, while it’s being processed on the support side, can you email me the project personally? I’d like to quickly glance at it and see the code right now, in case there’s something I’m unclear on. Email is brent (at) coronalabs (dot) com.

Brent

Ok, will do!

Hi @polygonblog,

In the project you sent me, there is no actual sprite animation going on (just two frames used for two different sprites, neither of which animate), so I can’t see the issues you mentioned above.

What I do see, however, is that the second object flickers and has some graphical glitches when the path is transitioned. This doesn’t appear to be a new issue (I tested with builds even earlier than 2992), but it’s clearly a bug which we’ll need to explore.

If you want to send me another project with actual frames to animate in a sprite sequence, please do.

Brent

Thanks for looking into this! You are correct there is no animation running, but graphical glitches show up just by showing any other frame than 1st from the sprite sequence.

Yes, good point… I’m seeing that too. Thanks for providing this test case!

This sounds a lot like a problem I had a few months ago. While I don’t really work with sprite sheets much, I experienced a similar problem when I switched to “repeat” for tiling the background and didn’t return it to “clampToEdge” for my non-power-of-two display objects.  Everything worked fine in the simulator but distortions or omissions occurred on devices.

Have you changed the default texture wrapping with display.setDefault( ) from “clampToEdge” to “repeat” or “mirroredRepeat”?

If you are using any third party code or a plugin, changes to the default settings might have sneaked in.  That’s what happened to me.

Once I finished tiling the background I switched the defaults back to “clampToEdge” and all was fixed.

[lua]

display.setDefault( “textureWrapX”, “clampToEdge” ) 

display.setDefault( “textureWrapY”, "clampToEdge " )

[/lua]

Maybe something similar is happening in your case?

Thank you sharp100 for you suggestion. I tried all the texture wrapping modes but unfortunately it makes no difference. I see the same distortion/pixelation with all of them.  

It sounds like you are applying a distortion as path.y2 is the bottom left-hand corner of an object is this what you are trying to do?  More info

If you want to move it along a path then use a different method.

Yes I’m deliberately distorting the sprite object. It works as expected in simulator. The texture stretches but it still looks good. All frames of the animation sequences look good. On device all other frames except the 1st one, look terrible. Somehow pixelated and with jagged edges.