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 erezavidan · Jul 14, 2019 at 07:41 AM · scripting problemmesh vertices

mesh generation + normal maps

I'm trying to create a 3d maze out of a 2d grid of ones and zeros where 0 is a wall and 1 is a passage. as you can see in the picture below, the left wall looks correct, but the right wall looks like the normal maps are inverted. also the back and front facing walls look flat. maze

each wall is generated using

 Matrix4x4.TRS(new Vector3((j + .5f) * width, halfH, i * width),Quaternion.LookRotation(Vector3.left),new Vector3(width, height, 1)

with the corresponsing rotation, and then the matrix is used to generate this way:

         Vector3 vert1 = new Vector3(-.5f, -.5f, 0);
         Vector3 vert2 = new Vector3(-.5f, .5f, 0);
         Vector3 vert3 = new Vector3(.5f, .5f, 0);
         Vector3 vert4 = new Vector3(.5f, -.5f, 0);
 
         var verts = new Vector3[4];
 
         verts[0] = matrix.MultiplyPoint3x4(vert1);
         verts[1] = matrix.MultiplyPoint3x4(vert2);
         verts[2] = matrix.MultiplyPoint3x4(vert3);
         verts[3] = matrix.MultiplyPoint3x4(vert4);
         newVertices.Add(verts[0]);
         newVertices.Add(verts[1]);
         newVertices.Add(verts[2]);
         newVertices.Add(verts[3]);
 
         newUVs.Add(new Vector2(1, 0));
         newUVs.Add(new Vector2(1, 1));
         newUVs.Add(new Vector2(0, 1));
         newUVs.Add(new Vector2(0, 0));
 
         newTriangles.Add(index + 2);
         newTriangles.Add(index + 1);
         newTriangles.Add(index);
 
         newTriangles.Add(index + 3);
         newTriangles.Add(index + 2);
         newTriangles.Add(index);

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
0

Answer by Bunny83 · Jul 14, 2019 at 05:04 PM

Uhm, do you actually generate any normal vectors? If not, do you at least call RecalculateNormals() instead? We only see the code snipped you posted here. After you assigned all your data to your mesh you should call RecalculateBounds and if you did not generate any normals yourself you should call RecalculateNormals.

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

190 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 avatar image avatar image avatar image avatar image avatar image avatar image 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 can i create a Plane using this Mesh generator script ? 0 Answers

Alternatives to 3D boolean operations 1 Answer

how do i fix how i make triangels in my mesh 0 Answers

c# - List with multiple types - Trading Engine - Stock Simulator 2 Answers

variable not being changed outside of a method. [C#] 3 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