Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 Geocake · Nov 04, 2021 at 09:27 PM · texturemeshmaterialuvuv mapping

UV Mapping for 2D Meshes with 3 Vertices Only

Hello! I'm creating an area graph with multiple 2d meshes. I'm trying to add a material with a gradient to each 2d mesh using uvs. It works for meshes with 4 or more points, but meshes with only 3 vertices are invisible. How can I fix this problem? alt text

As you can see, all the meshes are drawn. However, the ones with only 3 points are not colored. The uvs for the first triangle (that doesn't work) are (0,1), (0,0), and (1,1). The uvs for the third triangle (that does work) is (1,0), (0.66,1), (0.33,1), and (0,0). This is my first time posting, so if there is any information you need, let me know. Any help would be appreciated!

screenshot-2021-11-04-161120.png (20.8 kB)
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 Eno-Khaon · Nov 05, 2021 at 12:17 AM 1
Share

It's a bit tough to tell for certain based on your description as-is. Specifically, you list 3 vertices for your "first triangle" and 4 vertices for your "third triangle", which distinctly doesn't describe a triangle.

It sounds like a winding-order (i.e. clockwise/counter-clockwise vertex order) issue with the Meshes themselves most likely, but it's hard to tell without knowing vertex positions and triangle ordering specifically.

avatar image Geocake Eno-Khaon · Nov 05, 2021 at 12:38 AM 0
Share

The meshes are triangulated using ear-clipping and the points are counter-clockwise, at least I think they are lol. And sorry about that I meant the third mesh. There's no such thing as a triangle with 4 points.

Here are the points and uvs of the first two meshes, which don't work and have 3 points each. alt text

Here are the points and uvs of the third. This has 4 points and is visible. alt text

screenshot-2021-11-04-203613.png (67.1 kB)
screenshot-2021-11-04-203750.png (45.7 kB)
avatar image Eno-Khaon Geocake · Nov 05, 2021 at 01:20 AM 1
Share

Well, with a quick test, I can already tell you that you'd want clockwise winding order on the vertices (or a double-sided shader that doesn't cull back faces). Based on punching in the numbers myself (but having no idea what your triangle ordering is like, so intentionally having non-matching shape results on the trapezoid shape), I'm fairly confident that this is the problem you're facing.

Show more comments

1 Reply

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

Answer by Bunny83 · Nov 05, 2021 at 01:33 AM

The meshes are triangulated using ear-clipping and the points are counter-clockwise, at least I think they are lol.

Well, first of all in Unity which uses a left handed system the winding order should be clockwise, not counter clockwise. Since you only "think" they are winding in a certain direction, I think you should clear that up because they may face into the wrong direction. However you can immediately check this by switching the camera into 3d mode and move it to the other side. If you see those missing triangles there, they have the wrong winding order. Though if you create those triangle from code, it should be quite easy to reason about the winding order when you pay attention.


Your screenshots of your vertices are not helpful at all since they are useless without the triangle definition. Also your meshes appear to be 2d meshes, why do your coordinates vary in all 3 axis? If they don't it's not really clear what those 3 values represent if it's not x, y and z.


It's also not clear how the texture actually looks like. Maybe you mapped an empty region? If you need further help with this, you should edit your question and add more details. Preferable the relevant code that generates the mesh or at least the exact vertex, uv and triangle data as text, not as an image.

Comment
Add comment · Show 1 · 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 Geocake · Nov 05, 2021 at 03:39 PM 0
Share

Thank you! It turns out the triangle ordering was counter-clockwise for meshes with only 3 vertices. (I didn't write the ear-clipping algorithm, so I don't know why that is.) Meshes with 4 or more points were ordered clockwise, which explains why the rest showed. All I did to fix this problem was reverse the list containing triangle ordering when there are exactly 3 vertices, turning counter-clockwise to clockwise.alt text

screenshot-2021-11-05-113428.png (5.7 kB)

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

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

Related Questions

How to change object scale but keep material with old scale by script? 0 Answers

2 Textures on a single mesh 1 Answer

can't put texture materials on imported mesh. 1 Answer

UV tiling to fill face? 1 Answer

Split a mesh while using same UVs and texture position. 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