Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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
2
Question by LukeZaz · Jul 18, 2015 at 11:50 PM · texturemeshuv

Texture bleeding on mesh

I've looked up and down for an answer on this, but can't find anything except answers that tell me to turn of mipmapping and set filter mode to point, which I've already done, and yet the problem persists.

I'm trying to make a procedurally generated mesh and in between every two triangles there is a line made up of the color of a neighboring texture from my texture atlas - in addition, it gets worse the farther away I get.

I've also seen suggestions to add extra space around each individual texture, but I'd rather avoid doing that if I can.

Pink lines intersect any time the texture repeats, farther away, these lines become increasingly visible to the point of hiding the rest of the texture

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

2 Replies

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

Answer by zach-r-d · Jul 19, 2015 at 12:23 AM

Try insetting your UV coordinates by .5*(textureSize/2f) so that sampling will occur in the middle of a texel rather than at the border between two texels. I've drawn a diagram to try to show what I mean:

half texel offset diagram

UV coordinates like those of the red outline in the upper left (.1,.6 to .4,.9) will get bleeding due to rounding errors. Using UV coordinates like those of the red outline on the right (.65,.45 to .85,.65) will mitigate the bleeding. The downside is that when the quad is viewed up very close, the grey border pixels may be noticeably cut in half. If that is unacceptable, the only solution is to go back to defining the UV coordinates along texel edges and doubling the border pixels, as with the red outline in the lower left (.1,.1 to .4,.4).


diagram.png (12.0 kB)
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 LukeZaz · Jul 19, 2015 at 06:32 AM 1
Share

If I'm understanding right, I should adjust my UV coordinates to be about half a pixel further in to the tile on every corner? I ask because while doing so (to be clear what I'm doing: (0.5 * (percentage of texture file taken up by individual texture / pixels per individual texture))) has fixed the problem up-close without any noticeable downside, I still see bleeding from far away.

While not a huge issue - since the distances required are unlikely to be encountered in my game - I was wondering if this was normal and/or fixable?

avatar image zach-r-d · Jul 19, 2015 at 07:48 AM 1
Share

Yep, that's exactly how it works. It mitigates bleeding but might not eli$$anonymous$$ate it completely.

I believe bleeding is unfortunately an inherent limitation of texture atlases. Even the lower-left case will probably fail at great enough distances. The only ways to be absolutely sure are to add enough border that the problem isn't visible while the geometry is in the camera's frustum, or to use individual textures with wrap mode set to clamp (which might not even be possible for terrain meshes).

Also, I'm not certain, but mipmapping and good texture filtering (trilinear or anisotropic) may now help rather hurt since there's border space on both sides of the uv coordinates; it's worth a shot.

avatar image whisp · Jan 17, 2016 at 10:19 PM 0
Share

Not a bad solution.

I assume you'll lose half a pixel on each side. $$anonymous$$g. if you take the 3 pixel wide square on the right side of zach.r.d's image, it's only the part within the frame that gets spanned from vertex to vertex. With a 3x3 pixels resolved tile that's a big deal and beco$$anonymous$$g less and less of a deal the higher the resolution.

avatar image
0

Answer by Barsonax · Dec 09, 2015 at 10:28 PM

To add to zach.r.d's answer you dont have to use 0,5 times the pixel width/height. I did this with a 16x16 pixels tilemap game and it looked horrible. What i did is instead of 0,5 times i did it with 0,01. It also eliminates bleeding but its pretty much invisible to the eye.

For reference iam using a custom unlit shader

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

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

Related Questions

Assigning UV Map to model at runtime 0 Answers

A way to "fold" a texture on a mesh? 1 Answer

Remove annoying texture offset on custom mesh 0 Answers

Tile Texture Smearing 1 Answer

Does Unity support multi-tile texture workflows? 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