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
1
Question by CeejayZSmith · Mar 15, 2013 at 09:33 PM · planeverticesnoiseperlin

Perlin Noise Plane Manipulation

i want to start using Perlin Noise to manipluate vertices on a plane but i have no idea how, how can i get data from a perlin noise to move vertices on the y axis? i have a for loop going through all the vertices but how do i get data from a perlin noise to give me a y position?

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
3
Best Answer

Answer by robertbu · Mar 15, 2013 at 10:55 PM

Use Mathf.PerlinNoise(). There is an example in the reference page that creates a grayscale texture. It should be fairly straight forward to modify the example to instead change the y values of your plane.

Comment
Add comment · Show 4 · 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 CeejayZSmith · Mar 15, 2013 at 11:51 PM 0
Share

I've looked at that but I didn't now what to use for the y position

avatar image robertbu · Mar 16, 2013 at 02:36 AM 0
Share

Below is an example script. You will have to adjust the power and scale parameters to fit the resolution of your plane. You can hit the space bar to generate a new starting point (i.e. sample another point on the plane). The CreatePlane script in the Wiki is a nice way to generate higher resolution planes. Note the noise seems to be reflected about the x axis, so using this script you can create an anchor (top left for example) that places the plane all on one side of the origin. Here is a sample output:

alt text

     using UnityEngine;
     using System.Collections;
     
     public class PerlinNoisePlane : $$anonymous$$onoBehaviour {
         public float power = 3.0f;
         public float scale = 1.0f;
         private Vector2 v2SampleStart = new Vector2(0f, 0f);
     
         void Start () {
             $$anonymous$$akeSomeNoise ();
         }
         
         void Update () {
             if (Input.Get$$anonymous$$eyDown ($$anonymous$$eyCode.Space)) {
                 v2SampleStart = new Vector2(Random.Range (0.0f, 100.0f), Random.Range (0.0f, 100.0f));
                 $$anonymous$$akeSomeNoise();
             }
         }
             
         void $$anonymous$$akeSomeNoise() {
             $$anonymous$$eshFilter mf = GetComponent<$$anonymous$$eshFilter>();
             Vector3[] vertices = mf.mesh.vertices;
             for (int i = 0; i < vertices.Length; i++) {    
             float xCoord = v2SampleStart.x + vertices[i].x  * scale;
             float yCoord = v2SampleStart.y + vertices[i].z  * scale;
                 vertices[i].y = ($$anonymous$$athf.PerlinNoise (xCoord, yCoord) - 0.5f) * power; 
             }
             mf.mesh.vertices = vertices;
             mf.mesh.RecalculateBounds();
             mf.mesh.RecalculateNormals();
         }
     } 
 
 
   [1]: http://wiki.unity3d.com/index.php?title=CreatePlane


perlinnoise2.jpg (29.6 kB)
avatar image CeejayZSmith · Mar 16, 2013 at 01:00 PM 0
Share

Thank you so much ive been trying to do this for a long time but why does my plane not look as hilly as your picture? the hills on $$anonymous$$e are very small and when i ajust the power they become like sharp edges do you have a smooth function?

avatar image CeejayZSmith · Mar 16, 2013 at 01:07 PM 0
Share

never $$anonymous$$d i had to change the scale thank you so much for this it helped loads

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

10 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

Related Questions

Change a plane's vertices positions in runtime using a 2D array 0 Answers

easy c# Simplex Noise script code 1 Answer

Using noise as texture 2 Answers

Applying noise to a texture 1 Answer

Animated distortion of vertices 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