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 /
avatar image
0
Question by DavidChenware · Feb 13, 2014 at 06:45 PM · 2dtexturespritealphatransparent

How to get rid of dark line on the edge of transparent pixels?

I have a sprite sheet that has each sprite in a 32x32 pixel area. I am using the Tiled map editor, that exports sprite map data as XML, allowing me to build game maps in that editor. In Unity, I've written a script that takes the map XML, and the sprite sheet(s) that is(are) imported, and pieces together a new Texture2D based on the map XML and applies it to a sprite to generate the map and layers, etc.

There's one issue that I cannot figure out, and it's this dark line that shows up on the border between a tile, and a transparent space. Here is the image that describes my problem.

alt text

I have messed with various import settings already, such as the following:

  • Disable mip maps

  • Set filtering mode to Point

  • Clamp instead of wrap

  • Turn off compression, set to RGBA32

  • My texture is power of 2

  • My texture fits in the size of 4096, it IS 4096.

I've also read through this thread which details a problem that sounds very similar to mine, except there is no spare space around the tiles in the sprite sheet to stretch out colors to smooth stuff out, and I'm piecing together the final Texture2D in code.

The last tidbit that I think might be relevant is the fact that when I run in to a non-tile, in the map, e.g. if there's "nothing" in that area on the layer, I put a blank/clear tile in that spot with Texture2D.SetPixels() with a full Color[] of Colors.clear.

Thanks in advance for any help!

Comment
Add comment · Show 4
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 MakeCodeNow · Feb 14, 2014 at 03:23 AM 0
Share

Are you building one huge texture and rendering that on a single quad, or are you building a texture atlas and then mapping that to geometry in the scene?

avatar image DavidChenware · Mar 04, 2014 at 04:28 AM 0
Share

I am building one huge texture and rendering on a single Sprite, there will actually be 1 sprite per layer from Tiled.

avatar image MakeCodeNow · Mar 04, 2014 at 04:43 AM 0
Share

Ok, so that screen above is just one big quad, right? Do you see those lines when you look at the texture resource in Unity? I wonder if your code that rasterizes individual textures into the big sheet has an off-by-one in it and it's accidentally leaving a gap of one pixel.

avatar image nesis · Mar 04, 2014 at 08:10 AM 0
Share

It could be rounding errors... Are you using floats to iterate across the texture ins$$anonymous$$d of ints?

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by No_Username_Found · Apr 27, 2014 at 11:38 PM

You may want to check the Wrap Mode value for the texture. Select the texture (not object/prefab) from your project folder, and switch the Wrap Mode between Clamp and Repeat. This picture illustrates a bug similar to yours, though it isn't using XML. It may be helpful to your situation.

alt text


repeat vs clamp.png (400.3 kB)
Comment
Add comment · 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
1

Answer by thenegaverse · Dec 28, 2014 at 10:50 AM

The above answer addresses one issue in this instance, but it didn't cure it for me. If this method doesn't work for you, the other fix is to click the actual texture (Mine are all set to 2D sprites because I'm working with solid pixel art), when the texture/sprite asset is selected, look at your inspector and change the filter mode to Point instead of Bilinear or Trilinear. The point filter will cure that blur and get rid of those weird lines along the border of the actual sprite. In the above answer, their assets are textures.

TLDR, if you're working with sprites and your asset's texture types are set to "sprite", change the filter mode to Point to avoid any artifacting and loss of image info to your art!

peace

Comment
Add comment · 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

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

22 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 avatar image

Related Questions

Texture type -> Advanced -> Mesh type: how it works? 1 Answer

Rewrite simple alphamask fixed function shader to surface or cg shader 2 Answers

reset 2d animation(sprite sheet texture) 0 Answers

Tilling material on sprites it's not working correctly 1 Answer

How to break a sprite into shapes with script 1 Answer


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