Issues with repeating fills when using image sheets

I am working on a simple free plugin for Corona, to try out the plugin creation before releasing my shadow plugin, but I seem to have run into an issue with repeating fills when using image sheets.

In the plugin, the user can select between using image sheet based or individual image based repeating fills. However, using image sheet does not properly repeat the fill, so I thought to ask here if someone can point out what my mistake is, or if the issue lies within Corona or TexturePacker.

I have attached a simple project with the necessary code, image and sheet that demonstrate my issue, but here’s the code as well:

 

display.setDefault( "textureWrapX", "repeat" ) -- by using an image local imageTexture = { type = "image", filename = "window1/top.png" } local object1 = display.newRect( 160, 160, 256, 16 ) object1.fill = imageTexture object1.fill.scaleX = 0.0625 ------------------------------------------------- -- by using an imagesheet local sheetInfo = require("sheets.window1") local myImageSheet = graphics.newImageSheet( "sheets/window1.png", sheetInfo:getSheet() ) local imagesheetTexture = { type = "image", sheet = myImageSheet, frame = 9 } local object2 = display.newRect( 160, 200, 256, 16 ) object2.fill = imagesheetTexture object2.fill.scaleX = 0.0625

In the image, there are two objects. The one above is created using an individual image and the one below is created using an image sheet.

AFAIK, you can’t wrap texture sheet
https://docs.coronalabs.com/api/type/ImageSheetPaint/index.html#gotchas

I guess a workaround using a shader with the xy/wh of the repeated part of the texturesheet would be possible, i.e. write a shader, setup the texture coordinates and in the shader, limit/repeat the texture access to the area defined by your given coordinates.

Given your image I guess the plugin may be a 3x1 3x3 patch renderer? If that’s the case, you could simply stretch the middle tiles instead of repeating them?

I also do have code like this in my games and I support both, repeating and stretching - but I simply implemented the repeating option by creating as many quads for the repeated tiles, as required. I create a mesh, so it’s not that much of an overhead (compared to, f.i. creating lots of extra display objects instead).

I can’t believe I missed that, especially since I checked out that exact page yesterday. Thanks! :smiley:

That shader workaround might be overkill for this specific issue, but I will have a look at using meshes. As for repeating versus stretching, I currently have both of them already in the plugin (as seen in the attached image), it’s just that I ran into issues with the repeating fill. Thanks for the tips!

AFAIK, you can’t wrap texture sheet
https://docs.coronalabs.com/api/type/ImageSheetPaint/index.html#gotchas

I guess a workaround using a shader with the xy/wh of the repeated part of the texturesheet would be possible, i.e. write a shader, setup the texture coordinates and in the shader, limit/repeat the texture access to the area defined by your given coordinates.

Given your image I guess the plugin may be a 3x1 3x3 patch renderer? If that’s the case, you could simply stretch the middle tiles instead of repeating them?

I also do have code like this in my games and I support both, repeating and stretching - but I simply implemented the repeating option by creating as many quads for the repeated tiles, as required. I create a mesh, so it’s not that much of an overhead (compared to, f.i. creating lots of extra display objects instead).

I can’t believe I missed that, especially since I checked out that exact page yesterday. Thanks! :smiley:

That shader workaround might be overkill for this specific issue, but I will have a look at using meshes. As for repeating versus stretching, I currently have both of them already in the plugin (as seen in the attached image), it’s just that I ran into issues with the repeating fill. Thanks for the tips!