Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Issues with repeating fills when using image sheets
Started by XeduR @Spyric Oct 27 2018 04:44 PM

3 replies to this topic
texturepacker image sheet sprite sheet image fill repeating fill

[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 773 posts
  • Corona SDK

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.

 

Attached Files



[TOPIC: post.html]
#2

fungrip

[GLOBAL: userInfoPane.html]
fungrip
  • Enthusiast

  • 56 posts
  • Corona SDK

[TOPIC: post.html]
#3

Michael Flad

[GLOBAL: userInfoPane.html]
Michael Flad
  • Contributor

  • 231 posts
  • Corona SDK

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).



[TOPIC: post.html]
#4

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 773 posts
  • Corona SDK

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


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

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!

Attached Files




[topic_controls]
[/topic_controls]