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 Benjames · Aug 31, 2018 at 04:41 PM · sphereprocedural meshcubemapmultidimensional array

Neighboring grid slots on a cube sphere?

So I have a cube sphere... I've been working hard to create a height terrain on it without screwing up the seams. Anyways I wrote this code to take neighboring slots and find an average height between them to smooth out the terrain. The problem is that near the seams the smoothing looks stretched, almost like its getting some neighbors twice.

alt text

  public void Smooth() {
             for (int tt = 0; tt <cube.g.g.Count; tt++) { //loops through 6 sides of cube sphere
                 for (int i = 0; i < cube.g.g[tt].g.Count; i++) { //loops through x of 2d grid
                     for (int j = 0; j < cube.g.g[tt].g[i].g.Count; j++) { //loops through y of 2d grid
                        float avg = GetAverage(tt, i, j);
                     }
                 }               
             }
         }
     
         float GetAverage(int tt, int i, int j) {
             float average_height = 0;
             float average_count = 0;
             for (int xx = (int)(average_amount*-1f); xx <= average_amount; xx++) {
                 for (int yy = (int)(average_amount*-1f); yy <= average_amount; yy++) {
     
                     Vector2 point = new Vector2(-1, -1);
                     Vector3 p = cube.g.g[tt].g[i].g[j].point;
                     p = Quaternion.AngleAxis(xx, Vector3.right) * p; //<<what I think is 
                     p = Quaternion.AngleAxis(yy, Vector3.forward) * p; //<<causing the problem
                     int ty = cube.g.getSlotfromNorm(p, cube.gridSize,ref point); //gets slot from position
                     float amount = 150;
                     if (point.x != -1 && point.y != -1) {
                         amount = Mathf.Abs(cube.g.g[ty].g[(int)point.x].g[(int)point.y].point.magnitude) - cube.radius;
                     } else {
                         print("Fail");
                     }
                       
                     average_height += amount;
                     average_count++;
                 }
             }
             average_height /= average_count;
     
             int vslot = cube.g.g[tt].g[i].g[j].vertSlot;
             cube.chunks[cube.g.g[tt].g[i].g[j].chunkSlot].vert[vslot] = cube.g.g[tt].g[i].g[j].point.normalized*(cube.radius + average_height);
             return (average_height);
         }
 

I believe using Quaternion.AngleAxis() to get the neighboring position's is causing this but I'm not entirely sure. Going around the grid array setup for the sphere (like raycasting) is not ideal because I will use similar code for editing the sphere. Anyways any advice is welcome!

streching.png (488.4 kB)
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 eses · Aug 31, 2018 at 06:43 PM 1
Share

@Benjames - I 'm not much help, but there is in progress series by Sebastian Lague on YouTube about creating procedural planets. Check that out, maybe he took some other approach, at least the planet noise looks better on cube seams.

avatar image Benjames eses · Aug 31, 2018 at 06:52 PM 0
Share

Cool thanks

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

88 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

Related Questions

Procedural Mesh Generation: Creating a spherical sector 2 Answers

Unity ParticleSystem collision with wall. Coords on wall. 0 Answers

How to get a smoothed Icosphere procedurally 1 Answer

Render texture used as simple sphere map. Possible? 1 Answer

Applying texture to quads on procedural cube 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