Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by iamMichaelDavis · Jan 26, 2014 at 04:25 PM · 2dpositionorthographicpixel art

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:

 Everything is offset by one pixel :(

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

 The bottom row of pixels is only 7 pixels tall :(

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

untitled-3.png (20.3 kB)
problem-example.png (4.9 kB)
Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image nesis · Jan 27, 2014 at 01:24 AM 0
Share

Silly question, but how big is your Game tab's viewport? If you resize the tab, it'll scale up and down to maintain aspect ratio. A discrepancy with scaling might crop up there.

Other than that, it miiiight be texture import options. Some options convert the image format, but I'm not sure how that'd affect just one line of pixels...

avatar image iamMichaelDavis · Jan 27, 2014 at 04:55 AM 0
Share

Not silly at all, I wish it was a simple gotcha like that (and still hope it will be :) ). $$anonymous$$y Game tab was in a full screen window all its own on a second monitor, at 1920x1080.

avatar image POLYGAMe · Feb 22, 2014 at 02:43 AM 0
Share

Nice art! Love the style :)

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by iamMichaelDavis · Jan 27, 2014 at 01:24 AM

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. :(

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: http://drilian.com/2008/11/25/understanding-half-pixel-and-half-texel-offsets/

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?

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image nesis · Jan 27, 2014 at 01:27 AM 0
Share

Strange, it could be floating point rounding errors to do with distance and angle from the camera...?

avatar image iamMichaelDavis · Jan 27, 2014 at 05:00 AM 0
Share

All the positions are set in whole values and changing the z position of the camera or the GameObjects doesn't change anything :/

avatar image Romano · Feb 22, 2014 at 02:14 AM 0
Share

Thanks for this I've just been puzzling over it myself.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Faking orthographic zoom by scaling positions 1 Answer

How to properly set up quad positions for 2d with an orthographic camera? 2 Answers

Water system for 2D game 0 Answers

How to make 3d models look like 2d pixel art? 1 Answer

How to de-pixelize pixel art (smooth out) 2d 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges