Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 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 /
  • Help Room /
avatar image
0
Question by alfaro190 · Apr 10, 2017 at 10:31 PM · meshshadowproceduralnormalsprocedural mesh

Weird Artifacts in Mesh generated by Script

I would like to understand what I am doing wrong. I am parsing a file that is pulling the Normals from 3D program. The triangles everything seems to be in order. The mesh is produced perfectly but when the mesh is finish the shadows cast on it are very odd. I assume it has something to go with the normals?

alt text

Has anybody seen these on meshes before?

Things that I have tired: RecalculateNormals(); Still same result. I read something about spliting vertices but not quite sure how to do that. Each Triangle has its own vertices and maybe that is the problem.

here is the sample code below:

 public class BuildModel : MonoBehaviour {
     public TextAsset modelInfo;
     public List<int> Triangles = new List<int> ();
     public List<Vector3> Verts = new List<Vector3>();
     public List<Vector3> Norms=new List<Vector3>();
     // Use this for initialization
     void Start () {
         string infoText = modelInfo.text;
         string[] TriangleInfo=Regex.Split(infoText, "r\n|\r|\n" );
 //        Triangles.Clear ();
 //        Verts.Clear ();
         int index = 0;
         foreach (string line in TriangleInfo) {
             string[] info = line.Split (':');
             if (info.Length >= 6) {
                 string ID = info [0];
                 string v1 = info [1];
                 string v2 = info [2];
                 string v3 = info [3];
 
                 string Name = info [4];
                 string matName = info [5];
                 string normal = info [6];
                 Vector3 point1 = stringtoVector (v1,4);
                 Vector3 point2 = stringtoVector (v2,4);
                 Vector3 point3 = stringtoVector (v3,4);
 
                 Vector3 normalV=stringtoVector(normal,7);
 
                 Verts.Add (point1);
                 Norms.Add (normalV);
                 Verts.Add (point2);
                 Norms.Add (normalV);
                 Verts.Add (point3);
                 Norms.Add (normalV);
 
                 int newT = index;
                 int newT2 = index + 1;
                 int newT3=index+2;
                 index = index + 3;
                 Triangles.Add (newT);
                 Triangles.Add (newT2);
                 Triangles.Add (newT3);
 
             }
         }
 
         makeMesh ();
     }
 
     void makeMesh(){
         GameObject newMesh = new GameObject ();
         newMesh.AddComponent<MeshFilter> ();
         newMesh.AddComponent<MeshRenderer> ();
         Material mm=new Material(Shader.Find("Standard"));
         newMesh.GetComponent<MeshRenderer> ().material = mm;
         Mesh newM = newMesh.GetComponent<MeshFilter> ().mesh;
 
         newM.SetVertices (Verts);
         newM.SetTriangles (Triangles.ToArray(), 0);
         newM.SetNormals (Norms);
 //        newM.RecalculateNormals ();
 
         newMesh.transform.rotation = Quaternion.Euler(new Vector3(-90f,0f,0f));
 
 
     
     }
 
     Vector3 stringtoVector(string v_String,int amount){
         v_String=v_String.Remove (0, amount);
         v_String = v_String.Remove (v_String.Length - 1, 1);
 
         string[] splitV = v_String.Split (',');
 
         float x = float.Parse (splitV [0]);
         float y = float.Parse (splitV[1]);
         float z = float.Parse (splitV [2]);
 
         Vector3 parse_Point = new Vector3 (x, y, z);
         return parse_Point;
     }



capture.png (291.0 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
0

Answer by alfaro190 · Apr 11, 2017 at 01:16 AM

Not sure if this is the solution but, I went into my project settings and changed my shadow Projection to Stable Fit. Seem to fix the problem. Still skeptical about the solution. So wont mark it as answered

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

108 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

Related Questions

Problem with Procedural Mesh Generation 1 Answer

Is it possible to use face normals as vertex normals in procedurally generated meshes? 1 Answer

Generating Mesh "Around" 3D Dictionary 0 Answers

Some triangles are black on a mesh generated by script 1 Answer

Flat shaded mesh, strange triangle colors 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