2D Toolkit Forum

2D Toolkit => Support => Topic started by: esdot on August 21, 2014, 06:47:26 pm

Title: Can't seem to render pixels perfectly...
Post by: esdot on August 21, 2014, 06:47:26 pm
We're struggling to make pixel art render correctly....

Here you can see a dither test, in Photoshop, compared to 2dToolkit:
(http://cl.ly/image/180E2I132J0G/Image%202014-08-21%20at%2011.46.04%20AM.png)

You can see a distinct grid pattern forming on the image due to pixel distortion.

We're using Orthographic camera, with PPM set to 1 on both the camera and the asset. SpriteCollection is set to Point filtering.

No matter what I do, I can't get this Dither to render with perfection :(
Title: Re: Can't seem to render pixels perfectly...
Post by: esdot on August 21, 2014, 08:01:09 pm
Ok, so after download PixelPerfect from the asset store, and using it's PerfectPixel camera, we can get exactly what we need.
https://www.assetstore.unity3d.com/en/#!/content/14498

(http://cl.ly/image/1L2F1F282E3g/Image%202014-08-21%20at%201.00.01%20PM.png)

Seems to be related to the formula for doing screen scaling. If it doesn't scale by discrete steps, the pixels will get distorted. When you change zoom level, you get the following values for Orthographic Camera Size:
2 = 1.32
3 = .88
4 = .66
5 = .528
etc...


Is there a way to do this with tk2dCamera?
Title: Re: Can't seem to render pixels perfectly...
Post by: unikronsoftware on August 21, 2014, 08:02:59 pm
Your native resolution isn't the same as preview resolution? Set it to exactly the same numbers, i.e. keep native res = 1024x768, and be sure that the viewport resolution is set to 1024x768 in the game window, AND that you have 1024x768 pixels visible in the game window. I.e. the blue window should be should have a gray border on all sides.

As you can see, the resolution says "704x528" not 1024x768. Your game view is scaled.
Title: Re: Can't seem to render pixels perfectly...
Post by: esdot on August 21, 2014, 08:07:40 pm
Ya that does fix the issue... but in the real world, the game view will always be scaled, will it not? We need to adjust to devices from 800x400 to 4k monitors, all using Pixel Art...

With PixelPerfect, you can set pixel "zoom level", so we'd simply detect screen size at startup, and assign a zoom level to the camera that will give nice results on that size screen.

With tk2d, I don't see any way to make a dynamic sized camera, that always gives us whole pixels. Overrides seem device specific which is not ideal.

Title: Re: Can't seem to render pixels perfectly...
Post by: unikronsoftware on August 21, 2014, 08:12:16 pm
Thats what you use overrides for. Add a wildcard override and set it to pixel perfect for it to be pixel perfect at any resolution.
Title: Re: Can't seem to render pixels perfectly...
Post by: esdot on August 21, 2014, 08:39:21 pm
Oh I see... It's still not working though.

I had the Dither rendering correctly at 1024x768, and added the Pixel Perfect override.

When I publish the exe, and run at 1080p, it renders like this (zoomed in photoshop)
http://cl.ly/image/1Z2b1q0k1u1K/Image%202014-08-21%20at%201.38.52%20PM.png
Title: Re: Can't seem to render pixels perfectly...
Post by: unikronsoftware on August 22, 2014, 07:51:56 pm
Can you post a pic of your overrides panel? Does it render correctly if your published exe is running at 1024x768?