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 /
  • Help Room /
avatar image
1
Question by Emag2706 · Sep 22, 2020 at 07:46 PM · meshspheremeshrenderermesh verticestriangulation

How to link up vertices to form the triangles in a Fibonacci Sphere?

I have been working on generating my own Sphere meshes lately. The easiest method to achieve this, is by creating a cube first and then normalize the vertices so they are equidistant from a certain origin point. This works fine but there are a couple of problems with it.

Because I am generating the Cube first and the turning it into a Sphere, the Sphere is made of 6 sides (6 sides of the cube). This makes it difficult to distort the shape of the Sphere in any form as you have to make sure the edges of the faces stay lined up.

So I looked online for other ways of generating a Sphere mesh, and I came across the Fibonacci Sphere found in this article.

It is a pretty cool way but also very efficient as the vertices are spread fairly evenly over the surface of the sphere. The problem with this though is that I have no clue what the logic behind the triangles is going to be in this one. The cube one is fairly straightforward because I am essentially only making 6 planes which are simply a grid of vertices.

In this one, I can't really understand how everything is going to link up together. I can't really think of any algorithm that can create the outside triangles for any arbitrary number of vertices on the sphere and I couldn't find anything online about it.

For reference, here is how the vertices are spread out when I try to spread 500 points over the surface of the sphere: https://prnt.sc/ulzwdb

I used Gizmos to draw spheres at the points in which the vertices are located just to see if I could come up with a way to find the right vertex indexes for my triangles, but I couldn't.

Any help would be appreciated

Thank you in advance.

Here is the code that I am currently using for the vertices (and also a mess of triangles):

     public void createCircle(){
         Mesh mesh = new Mesh();
         vertices = new Vector3[resolution];
         triangles = new int[resolution*3];
 
         for(int i=0; i<resolution; i++){
             float theta = 2 * Mathf.PI * i / goldenRatio;
             float phi = Mathf.Acos((float)(1 - 2*(i+0.5)/resolution));
             Vector3 pointOnSphere = (new Vector3(Mathf.Cos(theta) * Mathf.Sin(phi),
             Mathf.Sin(theta) * Mathf.Sin(phi), Mathf.Cos(phi)) * radius) + transform.position;
             vertices[i] = pointOnSphere;
         }
 
         int vertexCount = 0;
         int triangleCount = 0;
 
         for(int i=0; i<resolution-2; i++){
             triangles[triangleCount] = vertexCount;
             triangles[triangleCount+1] = vertexCount+1;
             triangles[triangleCount+2] = vertexCount+2;
             vertexCount++;
             triangleCount+=3;
         }
 
         mesh.vertices = vertices;
         mesh.triangles = triangles;
         mesh.RecalculateNormals();
 
         if(sphereMeshFilter != null) sphereMeshFilter = new MeshFilter();
         MeshRenderer meshRenderer = this.gameObject.GetComponent<MeshRenderer>();
         MeshFilter meshFilter = this.gameObject.GetComponent<MeshFilter>();
         if(meshFilter == null){
             this.gameObject.AddComponent<MeshFilter>();
         }
         if(meshRenderer == null){
             this.gameObject.AddComponent<MeshRenderer>().sharedMaterial = new Material(shader);
         }
         meshFilter.mesh = mesh;
 
     }


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 Michael_Hutton · Sep 15, 2021 at 05:49 PM 0
Share

Did you manage to do this. I'm at exactly the same point you are here but would love to see if you managed it.

0 Replies

· Add your reply
  • Sort: 

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

228 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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

3D mesh vertices ,face was torn,why? 0 Answers

I want to change the coordinates of the plane to the sphere. 0 Answers

How important is the order of Vertices in the mesh array that the triangles point to? 0 Answers

How to turn off smooth polygon rendering via runtime 0 Answers

Failed Getting triangles & Failed setting Triangles - Using Quixel Voxel Terrain 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