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
1
Question by cre1467 · Oct 30, 2020 at 07:39 AM · textureuvuv mappingmeshfilteruv coordinates

Is it possible to UV map a cylinder without duplicating a column of vertices?

I've procedurally generated a mesh of a mushroom, and I'm currently trying to get the UV maps added to it. I've managed it no problem for the cap and gills, but I'm running into a problem with the stem. I've mapped all the vertices to equally spaced points in the UV plane, but the problem that arises is that the triangles between the last and first vertices now stretch the entirety of the plane, causing the squished texture you see here in the last column of triangles. Of course, I could duplicate the first row of vertices and have the mesh actually be disconnected along that line, but that would make the edge hard, and I don't want to do that. Besides, it seems rather inelegant to have that asymmetry in the geometry of what's essentially a cylinder. I've had to duplicate the rings joining the cap to the gills and the gills to the stem, which, while more aesthetically acceptable, is still unpreferable. Is there a way to reuse vertices in the UVs without creating hard edges?

model of mushroom with distorted texture

uvissue.png (266.2 kB)
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

1 Reply

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

Answer by Bunny83 · Oct 30, 2020 at 01:27 PM

No, there's no other way around that. However duplicating the vertices along the seam doesn't make it a hard edge. Relying on RecalculatNormals will produce a hard edge because it doesn't know about this "logical" connection. The easiest solution is if you don't want to calculate all normals manually to use RecalculateNormals and after that iterate through the seam vertices in pairs and simply calculate the average of the two normals and assign the resulting normal to each pair.


Since we don't know how you partition your vertices and how they are laid out in the array we can't give you the exact solution here. However it's something along

 mesh.RecalculateNormals()
 Vector3 normals = mesh.normals;
 for(int i = 0; i < heightVertexCount; i++)
 {
     int index1 = (calculate first vertex based on i);
     int index2 = (calculate paired vertex based on i);
     var n1 = normals[index1];
     var n2 = normals[index2];
     var n = (n1 + n2).normalized;
     normals[index1] = normals[index2] = n;
 }

This will assign the same normal to each pair of vertices at the seam. Of course if you need this a lot you could put the "combining / averaging code" in a seperate method

 static void AverageNormals(Vector3[] normals, int index1, int index2)
 {
     var n1 = normals[index1];
     var n2 = normals[index2];
     var n = (n1 + n2).normalized;
     normals[index1] = normals[index2] = n;
 }

So all you have to care about is calculating the right indices for your seam pairs.

Comment
Add comment · Show 2 · 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 Bunny83 · Oct 30, 2020 at 01:30 PM 0
Share

People often make the mistake and thinking of "vertices" just as "positions". However that's not what a vertex is. A vertex is a set of data that also includes the position in space but also the position in texture space. You want to have different texture space coordinates for those faces and therefore you need seperate vertices. You can only share vertices if all vertex attributes are the same.

avatar image cre1467 · Nov 02, 2020 at 11:21 PM 0
Share

This worked; thank you!

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

172 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 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

Assigning UV Map to model at runtime 0 Answers

Wrong import of UV from blender 1 Answer

Distorted/Warped Textures On Character Model After Bundling For Tabletop Simulator/In A Build 1 Answer

'.' is not a valid texture file name on asset warning/error 1 Answer

More materials smaller texture size vs less materials bigger texture size 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