• 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 Zoodinger · Aug 12, 2013 at 11:11 PM · meshnormalsvertexmerge

About merging meshes and their normals

Hello all,

This is my first question here ever. Sorry for the long post!

The situation: I have a room model that can have up to 4 possible doors (one for each side). When there is no door at the side, I'd like for the model to look closed there. Using my modelling program of choice (blender), I made an extra model which is a wall and closes exactly the gap as it should. This model uses a different area of the same UV texture.

As you might have already guessed, lighting there does look odd, in a way that makes it obvious the extra wall is a different object. I was expecting that. Merging the shapes improves it somehow, but contrary to my expectations you can still distinguish it even after recalculating the normals. I have even tried using a model of the base room without the faces that would overlap, with the same results.

Now, if I combine the models via Blender and remove the double vertices, the model looks perfect. Since the room is symmetric in 4 sides, assuming there are no rooms with no doors (because that'd make no sense) and assuming I can rotate but not mirror a mesh, there are really only 6 possible combinations. This isn't much at all; only +4 ~10-20kb models. The programming beast within me, however, growls at this solution, because there could be a time in the future when this solution would not be enough, since I plan to have different environments in the future.

So, what causes this issue, and how could I fix it? Merging the vertices sounds like a good idea, but won't that screw up the UVs? I assume that when blender exports, it separates a vertex into many if the UV coordinates are different for each face they belong to. But if that's true, then the imported room should be technically identical to the generated one, as it contains exactly the same vertices at exactly the same positions. One possible explanation is that there's some kind of very minor float precision problem which somehow causes the common vertices of the two combined meshes to not actually be identical.

Finally, in-editor solutions (if any) will not do because I'm using my own custom level editor and so everything is created during runtime in the beginning of each level.

~ Zoodinger

Comment
Add comment · Show 2
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 Boris1998 · Jan 21, 2014 at 12:13 PM 0
Share

So, you made room from combining 4 pieces of the wall and each 1 of them has their own lighting and it looks weird...same problem here...did you solve it and how?

avatar image Jessy · Jan 21, 2014 at 12:43 PM 0
Share

This is TL;DR unless you add illustrations. http://en.wikipedia.org/wiki/A_picture_is_worth_a_thousand_words

2 Replies

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

Answer by Zoodinger · Jan 23, 2014 at 01:11 PM

Hello Usul,

I actually fixed the problem a long time ago. The issue was that Unity uses a completely different method to calculate normals during import than during runtime. Runtime only fixes the normals of vertices shared by many faces, but it doesn't take into account other vertices that are in the same position. This especially happens when the model has UV coordinates, in which case the vertices must be different (as a vertex can't have different UV coordinates for different triangles).

Edit: I finally wrote an article about it that explains in detail what is going on. I also provided a working solution. I'm updating this, even though it's a very old question, because I know people will still find it useful.

The article is at: http://schemingdeveloper.com/2014/10/17/better-method-recalculate-normals-unity/

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 PaulUsul · Oct 28, 2014 at 11:05 AM 0
Share

That's an awesome article, I actually have use for something just like that at home :D thanks for writing here with it!

avatar image
0

Answer by PaulUsul · Jan 21, 2014 at 02:25 PM

Hi Zoodinger and welcome!

I expect that the reason they look different is because of the normals. You should put a shader on that visualizes this here's one..

  • Edit the normals in blender and fix it there(as far as I remember this is not possible).

  • Try and change the import settings on the models and make Unity recalculate normals instead of import them.

  • As a programmer you can manually replace/modify any/all normals through the Mesh class and "fix" them that way.

  • You can also add very small verts to the edges and use Mesh.RecalculateNormals.

but start by visualizing it :) hope my suggestions help!

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

18 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

Related Questions

Any script to 'fix' normals/winding order? 3 Answers

Unity shader vertex displace doesn't work 0 Answers

How can i manually calculate the normals for a terrain mesh? 0 Answers

Mesh Normal 1 Answer

Strange issue with generated mesh 2 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