Hello Guest

Author Topic: Pixel perfect rendering fails when trimming sprite sheets  (Read 6891 times)

oklo

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Pixel perfect rendering fails when trimming sprite sheets
« on: October 26, 2013, 11:27:53 pm »
Hi there!

I have a problem I can't seem to figure out at the moment (could be due to the late hour..). Basically I have a tilesheet with 64x64 tiles in it. Two wall tiles that should normally fit together perfectly does not do so, and to me it appears as if the trimming of tiles is to blame.

The camera is ortographic and both it and the spritesheet are set up with pixels per meter (20). The spritesheet is also set to point as the filtering mode. I've found out that by disabling trimming in spritesheet settings the problem goes away and everything appears to be pixel perfect, but I would ideally want the trimming in place to save place in the atlas.

Anyone have any clue as to what might be the problem?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Pixel perfect rendering fails when trimming sprite sheets
« Reply #1 on: October 27, 2013, 04:14:41 pm »
Does adding some padding (sprite collection settings, set padding to 1 or 2) improve quality?

oklo

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Pixel perfect rendering fails when trimming sprite sheets
« Reply #2 on: October 27, 2013, 06:59:48 pm »
No dice, the problem remains even if I add 1 or 2 under Pad Amount. Not sure what could be causing this as I've not had this problem in another project that uses the same tilesheets. I'll investigate some more.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Pixel perfect rendering fails when trimming sprite sheets
« Reply #3 on: October 27, 2013, 07:57:49 pm »
What kind of error are you seeing here?

oklo

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Pixel perfect rendering fails when trimming sprite sheets
« Reply #4 on: October 27, 2013, 08:08:57 pm »
I've attached 2 files showing the result with and without trimming enabled (two 64x64 tiles, one placed above the other). In case you want to investigate you can find a tiny unity project where the problem occurs for me located right here: link removed - only post links in the private support forum

It works perfectly when one disables trimming, the problem occurs when trimming is enabled. (The tilesheet is all yellow because I am not at liberty to share the artwork in use, but the problem is not exactly less visible with this bogus artwork)
« Last Edit: October 28, 2013, 11:53:54 am by unikronsoftware »

oklo

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Pixel perfect rendering fails when trimming sprite sheets
« Reply #5 on: October 27, 2013, 08:40:32 pm »
After some further investigation I've discovered that the problem is actually present both with and without trimming. The tiles should have 32 yellow pixels where they touch, but when trimming is disabled I am getting 33px - while if trimming is enabled I am getting 32px on the top one while 33px on the corner one at the bottom.

My guess is that it's a mistake on my part, I just don't see how or where...

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Pixel perfect rendering fails when trimming sprite sheets
« Reply #6 on: October 28, 2013, 11:54:27 am »
Hmmm... I don't see the issue at all. What platform / hardware are you running on?

oklo

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Pixel perfect rendering fails when trimming sprite sheets
« Reply #7 on: October 28, 2013, 01:46:26 pm »
It's just windows 7 with fairly typical pc hardware. Recent nvidia gpu.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Pixel perfect rendering fails when trimming sprite sheets
« Reply #8 on: October 28, 2013, 02:00:46 pm »
How big is your game window (physically)? What is the game window resolution set to? Is there some compression that is going on?

oklo

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Pixel perfect rendering fails when trimming sprite sheets
« Reply #9 on: October 29, 2013, 07:21:23 pm »
Just an update - the problem goes away when running a build instead of hitting play in the unity editor. It also goes away if I resize the scene window in the editor. The oddball screen resolution (in the editor scene window) of 1249x976 makes the problem visible for me, while most other similary odd resolutions seem fine. I don't see this is an important problem as seems to only occur for weird resolutions. Thanks for looking into the issue, and double thanks for making this great product :)

I also got this (most likely unrelated warning during build):
The private field `tk2dCamera.gameWindowResolution' is assigned but its value is never used

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Pixel perfect rendering fails when trimming sprite sheets
« Reply #10 on: October 29, 2013, 10:32:31 pm »
Yes this is definitely unrelated, and this won't cause any issues :) Thanks for mentioning it - I'll fix it in the next release.
The private field `tk2dCamera.gameWindowResolution' is assigned but its value is never used