x


2D plane not drawing texture correctly

Hi,

I'm new to Unity and trying to make a 2D game for iPhone. I'm using Sprite Manager 2 and have the camera set to orthographic with an orthographic size of 160 (for 480x320 landscape resolution).

I have a sprite that is 480x68 in size. I have applied the standard Sprite script from SM2 to the game object. When I play test the game, the camera looks right and the sprite looks correctly positioned, but the texture is slightly wrong. It has cut off a bit from the right side of the texture and stretched it. It also appears to be tiling slightly on the Y axis.

Screenshot of what the sprite looks like along with the settings I configured: alt text

Here is what the image should look like: alt text

How do I get the texture to appear correctly?

EDIT: Just noticed that you can't make out the settings, here they are: Width: 480 Height: 68 Lower Left Pixel: X: 0 Y: 67 Pixel Dimensions: X: 480 Y: 68

more ▼

asked Dec 06 '10 at 03:12 AM

disband85 gravatar image

disband85
11 3 3 7

I managed to fix this by changing the following values: Lower Left Pixel: X: 0 Y: 57 Pixel Dimensions: X: 500 Y: 58 However I would like to understand why this has fixed it, and find an algorithm for determining these values, rather than guessing them until it looks right.

Dec 06 '10 at 03:22 AM disband85
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Yes, the texture is being wrapped around if it's too small for the size of the sprite. The problem is trying to find the right, exact size (pixel dimensions) for the texture to fit the sprite. After doing many sprites now, there seems to be no method for figuring this out apart from guessing. Basically I make the pixel dimensions the same size as width and height initially, then run in game and keep changing pixel dimensions until the texture fits properly. It seems to be completely random as to how much you need to change it (doesn't correlate to image size of your texture at all).

One thing I did notice is that most of the time, the lower left pixel Y should be the same as pixel dimensions Y. Changing the lower left pixel X and Y offsets the texture by the respective axis.

more ▼

answered Dec 09 '10 at 02:46 AM

disband85 gravatar image

disband85
11 3 3 7

(comments are locked)
10|3000 characters needed characters left

It appears that the top of your sprite is being wrapped-around to the bottom of your image. This could be a UV problem (where the UV's of your object are out of alignment) or a case where the sprite is not being aligned like you think is should. I don't know much about Sprite Manager 2, but perhaps the texture has been compressed? A power-of-2 texture size height might give you better results (but, then again, 58 isn't a power of two...)

more ▼

answered Dec 06 '10 at 05:51 AM

The_r0nin gravatar image

The_r0nin
1.4k 10 14 30

thanks for your suggestion. You're right in that the texture wraps around. I don't think the UV alignment is wrong, more like the wrong size (eg. 0 - 0.7 instead of 0 - 1). Making the pixel dimensions powers of 2 didn't help.

Dec 09 '10 at 02:50 AM disband85
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2279
x2014
x1071
x266
x96

asked: Dec 06 '10 at 03:12 AM

Seen: 2432 times

Last Updated: Dec 06 '10 at 03:12 AM