Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 batch · Feb 12, 2014 at 02:30 PM · proceduralplanetperlin noisenoiseperlin

3D Perlin Noise mesh even in all axes

Hello! I'm using 3D Perlin Noise to generate a planet and I'm having an issue. Problem is that the planet's vertices aren't moving outwards evenly, they seem to be moving sort of where all three axes meet.

Here's an image:

alt text

The images on the left and right are either end, basically where x,y and z are all even, and the middle one shows how it looks stretched and isn't working evenly all round the mesh.

Here's the function I'm using:

     void GenerateMesh()
     {
         perlin = new Perlin();
         fractal = new FractalNoise(h, lacunarity, octaves, perlin);
         
         Mesh mesh = GetComponent<MeshFilter>().mesh;
         baseVertices = mesh.vertices;
         Vector3[] vertices = new Vector3[baseVertices.Length];
 
         for(int i=0;i<vertices.Length;i++)
         {
             Vector3 vertex = baseVertices[i];
 
             // Normalise the cube to make a quadsphere
             vertex = vertex.normalized ;
 
             float fractalNoise = fractal.RidgedMultifractal3 (vertex.x, vertex.y, vertex.z, offset, gain);
             fractalNoise = fractalNoise * scale;
 
             vertex.x += fractalNoise;
             vertex.y += fractalNoise;
             vertex.z += fractalNoise;
 
             vertices[i] = vertex;
         }
 
         mesh.vertices = vertices;
 
         if (recalculateNormals)
             mesh.RecalculateNormals();    
         mesh.RecalculateBounds();
     }

Which calls this Ridged Multi-fractal function which I modified from the Unity Procedural Demos program to work for 3D. This might be what I've done wrong, I'm not sure.

     public float RidgedMultifractal3 (float x, float y, float z, float offset, float gain)
     {
         float weight, signal, result;
         int i;
         
         signal = Mathf.Abs (m_Noise.Noise (x, y, z));
         signal = offset - signal;
         signal *= signal;
         result = signal;
         weight = 1.0F;
         
         for (i=1;i<m_IntOctaves;i++)
         {
             x *= m_Lacunarity; 
             y *= m_Lacunarity;
             z *= m_Lacunarity;
             
             weight = signal * gain;
             weight = Mathf.Clamp01 (weight);
             
             signal = Mathf.Abs (m_Noise.Noise (x, y, z));
             signal = offset - signal;
             signal *= signal;
             signal *= weight;
             result += signal * m_Exponent[i];
         }
         
         return result;
     }


Does anyone know where I'm going wrong?

Thank you!

screen shot 2014-02-12 at 14.10.40.png (202.4 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
1
Best Answer

Answer by robertbu · Feb 12, 2014 at 02:35 PM

In a quick read, I suspect lines 20 - 22 in the first script. I think you want to replace them with something like:

 vertex *= fractalNoise;

Or if you want a scale value of 0 to equal unchanged:

 vertex *= (1.0f + fractalNoise);


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 batch · Feb 12, 2014 at 02:41 PM 0
Share

Perfect! That fixed it. Thank you!!

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

19 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

Related Questions

How to use Perlin Noise for waves 0 Answers

Always same result from Mathf.PerlinNoise() 2 Answers

Unity Perlin Noise Bug? 3 Answers

Perlin noise problem 0 Answers

how do i procedurally generated perlin noise infinitely c# 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