Hello Guest

Author Topic: Gaps within tk2dStaticSpriteBatcher  (Read 17870 times)

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Gaps within tk2dStaticSpriteBatcher
« Reply #15 on: November 14, 2014, 01:08:41 pm »
No the padding is performed during the atlasing stage, you'll need to make sure your source images are dilated appropriately.

robinouu

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Gaps within tk2dStaticSpriteBatcher
« Reply #16 on: November 14, 2014, 05:50:10 pm »
Hum... How do I do it ?
If I understand correctly, I have to make an extra padding of 1pixel between each sprite in my custom atlas ?

(Seems to be an issue with Unity3D, not specifically tk2d)

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Gaps within tk2dStaticSpriteBatcher
« Reply #17 on: November 14, 2014, 08:10:57 pm »
This is not exactly an issue with unity either, its just what you'd do with tiled gpu textures. You can do it in photoshop, or just import your sprite collection into tk2d.

robinouu

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Gaps within tk2dStaticSpriteBatcher
« Reply #18 on: November 14, 2014, 08:33:09 pm »
I have to do it by code, because we use a custom editor for tile mapping and creating atlases :P

robinouu

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Gaps within tk2dStaticSpriteBatcher
« Reply #19 on: November 14, 2014, 09:49:02 pm »
I added the feature by code but gaps are still here...
I need to add the texture dynamically, I can't assign it by the tk2d spritesheet editor

Some ideas ?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Gaps within tk2dStaticSpriteBatcher
« Reply #20 on: November 14, 2014, 11:32:59 pm »
If you need to add it dynamically you'll need to make sure it is there in the source texture itself - you want to do that at asset author time, reading and writing textures is a slow operation you dont want to be doing while the game is loading / running.

robinouu

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Gaps within tk2dStaticSpriteBatcher
« Reply #21 on: November 15, 2014, 09:05:10 am »
I implemented your solution at author time (in our custom editor).

With 1 pixel padding between sprites :


The spritesheets are then loaded into Unity3D, but the gaps subsists.
What am I doing wrong ?


unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Gaps within tk2dStaticSpriteBatcher
« Reply #22 on: November 15, 2014, 11:32:28 am »
Extend padding duplicates the last pixel, I'm guessing the hole you see is the transparent bits there but I could be wrong. Hard to guess whats going on here, post a repro case and I can take a look.

robinouu

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Gaps within tk2dStaticSpriteBatcher
« Reply #23 on: November 21, 2014, 08:46:45 pm »
I still have gaps with float coordinates.
What is the algorithm for duplicating the last pixel, I don't understand.

If I can't find out, I will reproduce the problem with a minimal code and post it here.

robinouu

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Gaps within tk2dStaticSpriteBatcher
« Reply #24 on: November 21, 2014, 09:52:00 pm »
Here is the repro case : REMOVED LINK
Use the horizontal or vertical axes to move around.

Thank you for your assistance.
« Last Edit: November 22, 2014, 11:14:22 am by unikronsoftware »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Gaps within tk2dStaticSpriteBatcher
« Reply #25 on: November 22, 2014, 11:22:58 am »
You have an actual gap in your sprites, not sure how thats happened. Eg. if you zoom in a lot you'll see the gap. I cant see your source image, but it looks like you've not duplicated the pixel but instead added a black border? All you want to do is copy the last pixel into the gap.

robinouu

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Gaps within tk2dStaticSpriteBatcher
« Reply #26 on: November 22, 2014, 11:49:00 am »
I did not add a black border, the source image is the attached image in the above post.
I implemented your solution at author time (in our custom editor).

With 1 pixel padding between sprites :


The spritesheets are then loaded into Unity3D, but the gaps subsists.
What am I doing wrong ?



i added transparent borders between sprites, but now i have to fill them the same color as the last pixel of the sprite ?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Gaps within tk2dStaticSpriteBatcher
« Reply #27 on: November 22, 2014, 02:51:10 pm »
Quote
Extend padding duplicates the last pixel, I'm guessing the hole you see is the transparent bits there but I could be wrong.
You're seeing through into the background. Change the bg color and you can see that is the case.

You need to perform the equivalent of extend padding in tk2d, which is to copy the edge pixels, it should not be transparent. Copy the pixels into the empty space and it should fix the issue.

robinouu

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Gaps on screen
« Reply #28 on: November 23, 2014, 03:19:02 am »
It's finally working =) Copying the edge pixels is the right way to do.

Thanks for your help!