Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Drakonno · Dec 30, 2015 at 07:01 AM · meshcustomuv mappingmeshfilter

How to set UV (Map) for Mesh made by script without duplicating vertices?

Hello, and Happy New incoming Year!

// Story
I get an idea to create a "spiral stairs generator". Since in my "game" should be many multi-leveled buildings, and I'd like to have nice architecture, spiral stairs are must. Normally I'd make a spiral stairs in Blender, set everything there and import into Unity. But, let's say that I want different step length, so I have remade whole model. Using physics is also hard, since I don't have acces to single step. Och, and changing amount of steps is also remaking whole model.

Having that in mind I wrote script, which can quite well generate it for me. I'm making mesh from scratch of single step. Create multiple steps, then set their positions, and set steps as children of "mother-stairs". Simple math.

// Question
However, there is going UV. I know, that UV is Vector2 with X,Y variables from range <0;1>, where values are percentage of width and height of texture (nice feature for different texture resolutons).

This is the effect of "hard set" for vertices.

alt text

Almost well.

In theory my Mesh (are), and its UVMap (should) look like this: alt text

// TL;DR
As You can see in picture above, there are many occurences of one vertice in UVMap. Is there any way, to made proper UVMap without duplicates? If it's impossible, how to do duplicate it easily and properly?

Thank You in advance,
Drakonno

problem.png (443.9 kB)
theory.png (11.1 kB)
Comment
Add comment · Show 1
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 Fattie · Dec 30, 2015 at 04:17 PM 1
Share

Just BTW unrelated to your question. When generating objects, sometimes it is better to $$anonymous$$.I.S.S. I would consider making a routine which generates one GameObject being "one step unit", that is to say one riser + tread (plus carrier, nubs, or anything else).

For example, say you are generating a room. It's often better to simply have four separate GameObject for the walls, rather than one GameObject.

Apart from anything else, it's much easier to unit test, modify and so on. That's what I've found! Cheers

PS http://www.tradestairs.com/acatalog/stair-ter$$anonymous$$ology.GIF

2 Replies

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

Answer by Cherno · Dec 30, 2015 at 11:10 AM

It's possible for the vertices 1,2,3 and 4 in your schematic if they are laid out like that. The rest has to be duplicated, there's no way around it. It's what Unity does anyway when you import a mesh with shared vertices but where the UV map is laid out with unshared vertices. In the end, as long as you don't create a mesh that doesn't need to be cut at edges, you'll be better of just generating each face seperately, without shared vertices.

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 Drakonno · Dec 30, 2015 at 01:45 PM 0
Share

Thank You. If noone will get better idea, I accept this as answer. :)

avatar image
2

Answer by Fattie · Dec 30, 2015 at 04:11 PM

There is absolutely no problem with duplicating vertices.

This is something of a misunderstanding in 3D mesh tech. Note that in your case it's inconceivable you could need to reduce the amount of vertices. So there's just absolutely no problem at all with having "duplicate" (you could say "normal") vertices; there is no downside, it's simpler and in many ways better, it's the normal thing to do and you should do it!

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 Cherno · Dec 30, 2015 at 08:50 PM 0
Share

I'd like to add that it CAN become a problem when creating meshes with a lot of vertices, as they may only have ~65k vertices. Also, assigning a collision mesh is faster the less vertices it has. In the end, this can be avoided by dividing a large mesh into chunks, which is how most games do it.

avatar image Fattie Cherno · Dec 30, 2015 at 11:09 PM 0
Share

For sure. As I said "in your case it's inconceivable you could need to reduce the amount of vertices".

You never, as a broad rule, use mesh colliders (generally the only time mesh colliders are used in vid games, is as the ground or terrain).

As you say if you are (for some incredible reason) making a mesh that has tens of thousands (!) of vertices, you would be dividing it up in some way.

In any event, the absolute fact is, in the actual situation presented, they should be shared ! Happy new year!

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

35 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

Related Questions

Mesh filters missing their meshes when project cloned from bitbucket 2 Answers

Array index is out of range in MeshMorpher 2 Answers

Can't change verts on mesh after assigning to meshfilter. 1 Answer

Creating a mesh for an overview map 0 Answers

Number of mesh vertices increase when imported into unity 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