Why is this pixel art not lining up correctly?

I am trying to make a pixel game with Unity 4.3.3f1 and the 2D tools.

I have a background sprite (BG) that is 512 x 128 pixels. I have an avatar sprite (EGO) that is 16 x 32. For both sprites the Pixels To Units has been set to 1, the Filter Mode has been set to Point, and the Max Size has been set correctly (512 for BG, 32 for EGO), with the Format set to Truecolor.

The GameObjects containing the BG and EGO have been placed in the scene using whole numbers for position, and the Main Camera’s Orthographic Size has been set to 40 (the iPhone 5S resolution is 1136 x 640, divide that into 8 x 8 cubes and you get 142 x 80, which is what the game’s native resolution is meant to be, and my admittedly limited understanding is that you want to set the Camera Size to half the vertical height of your intended resolution).

When I set the Game window’s output resolution to a fixed 1136 x 640, this is what I see:

It’s actually kind of hard to see here, but there is 1 row of pink pixels at the very top, you can see a full sized version of that image at http://iammichaeldavis.com/staging/problem-example.png.

So everything is offset vertically by one pixel, and I have no idea why. I am a complete Unity newb so it’s entirely possible I’ve overlooked one super obvious piece of information, so I apologize if this is a stupid question. I searched for pixel art in the archives but it seems like since these 2D tools are so new people are still kind of figuring them out? I’ve also uploaded a .zip file of the project itself, which is at http://iammichaeldavis.com/staging/pixel-unity-problem.zip.

My knee-jerk guess was that it was a stretching issue, and Unity was stretching the background differently than the EGO sprite, so I took a screenshot into Photoshop and almost all the individual pixels of the originals do appear to be scaled up to an exact 8 x 8, except for the bottom row of the EGO sprite (which is only 7 pixels tall):

So, something is definitely off with the scaling. Is this a known issue?

So it turns out, if I set the camera’s Y position to -0.1, everything snaps into place, the scaling issue is fixed, all the pixels are upscaled by exactly 8 and everything lines up properly. So, I figured out HOW to fix it, but I have no idea WHY that works. :frowning:

edit --------

So, after a few weeks of messing around, and compiling a few builds to test stuff, it just seems, like, this is just how it has to be. If I reset the camera’s position to where it should be (40 instead of 39.9) everything shears and tears by one pixel in a compiled build, but if I keep it that 10th of a point off, everything lines up in a Mac and PC build, so, it just is what it is, I suppose. At least I figured out a working hack. So for future generations: if your rendering seems off in your pixel game, try scooting the camera around incrementally

another edit ---------

So, this might explain what the problem is: Understanding Half-Pixel and Half-Texel Offsets – JoshJers' Ramblings

Apparently the camera needs to be offset by a half-pixel when using Direct3D 9 on Windows. I’ll try to follow up with a Mac and see what I see, cause I’m on Windows 8 and I’d assume, Direct3D 10 or 11?