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 MountDoomTeam · Oct 19, 2012 at 06:12 PM · meshrandomprocedural

Substituting Sinus function with Perlin noise?

2D Perlin noise has an X and Y axis so it's basically a zigzag function.

please explain how to use the Mathf.PerlinNoise instead of Mathf.Sin to set the mesh coordinates abit randomly.

 // Code from procedural examples to sine-ify a mesh
 
 var scale = 10.0;
 var speed = 1.0;
 private var baseHeight : Vector3[];
 
 function Update () {
     var mesh : Mesh = GetComponent(MeshFilter).mesh;
     
     if (baseHeight == null)
         baseHeight = mesh.vertices;
     
     var vertices = new Vector3[baseHeight.Length];
     for (var i=0;i<vertices.Length;i++)
     {
         var vertex = baseHeight[i];
         vertex.y += Mathf.Sin(baseHeight[i].x ) * scale;   //<<<---THIS LINE PLEASE :)
         vertices[i] = vertex;
     }
     mesh.vertices = vertices;
     mesh.RecalculateNormals();
 }


EDIT-okay so here is a three-dimensional Perlin mashed deformation script, there are other noise functions on the forums that may have more control of the noise.

 var scale = 0.40;
 var speed = 1.0;
 private var baseHeight : Vector3[];
 
 function Update () {
     var mesh : Mesh = GetComponent(MeshFilter).mesh;
     
     if (baseHeight == null)
         baseHeight = mesh.vertices;
     
     var vertices = new Vector3[baseHeight.Length];
     for (var i=0;i<vertices.Length;i++)
     {
         var vertex = baseHeight[i];
         vertex.y += Mathf.PerlinNoise(baseHeight[i].x*3+77,12) * scale;
         vertex.x += Mathf.PerlinNoise(baseHeight[i].z*2+77,22) * scale;
         vertex.z += Mathf.PerlinNoise(baseHeight[i].y*3+77,42) * scale;
         vertices[i] = vertex;
     }
     mesh.vertices = vertices;
     mesh.RecalculateNormals();
 }
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

Answer by phodges · Oct 19, 2012 at 06:30 PM

The Perlin noise function accepts a pair of values, for your case you might consider feature baseHeight[i].x and z into it. Send those numbers, or any transformation of them that amuses you, into the Perlin method and then scale the result similarly to how you are making use of Sin. Note that the returned value is in the range 0,1 and so if you want your results to be in the same range as your previous experiment then double the output from the noise function and subtract 1.0.

Comment
Add comment · Show 6 · 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 MountDoomTeam · Oct 19, 2012 at 06:52 PM 0
Share

so to make a sin it's x = $$anonymous$$athf.Sin(y) and to make a perlin graph it's x= $$anonymous$$athf.PerlinNoise(y,1) for example? where could i get some pics/info's ?

is one of the 2 variables the number of octaves of the perlin function? same as these perlin 2d graphs: http://libnoise.sourceforge.net/glossary/index.html#octave

avatar image phodges · Oct 19, 2012 at 06:58 PM 0
Share

Google will give you as much Perlin noise as you can handle. What I would suggest though is that you build yourself a test scene and just play with some meshes.

avatar image MountDoomTeam · Oct 19, 2012 at 07:10 PM 0
Share

okay, because somewhere on the forums should say which of the 2 variables of the function is a modifier/seed, and what kind, and which is a linear input at 1st glance, it seems neither of the variables controls either the octave or the frequency, it is probably a seed, and frequency can be controlled by multiplying one of the values.

avatar image phodges · Oct 19, 2012 at 07:13 PM 0
Share

The documentation is a bit sparse, just saying it's a 2D Perlin noise generator. Ordinarily, I would expect there to be some other control for seeding it but that doesn't seem to be present. Worst comes to the worst, you could implement the noise generator yourself if there's not enough control in there for you.

avatar image MountDoomTeam · Oct 19, 2012 at 07:37 PM 0
Share

thanks phodges! someone has made 30 noise generators for unity:) http://u3d.as/content/chaos-cult/coherent-noise/1Uc

Show more comments

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

Generate a mesh from randomly positioned points 0 Answers

Selecting a single polygon / face at runtime 1 Answer

Can I use bytes instead of floats for vertices? 1 Answer

Procedurally generated mesh randomly appearing invisible 2 Answers

Flattening a mesh based on hit.point 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