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
2
Question by Saitodepaula · Aug 08, 2012 at 11:16 PM · noiseperlin

Perlin noise continuous through different objects

I want to use a Perlin noise function that acts continuously through different objects (planes in this case), wich means, with no gaps between vertices of different meshes. I've attached the script that applies the Perlin noise in a parent game object (an empty game object). The script runs the Perlin noise function once and search for the childrens (the planes), applying the noise to each vertex of each plane.

It worked when the noise is applyied only in one direction, but it doesn't when two or more directions are used. This question seems to use the same idea I have here, but I've tried many things suggested by the answers and comments provided there and could not come to a solution (Actually, I didn't understand some of the code provided there, I'm not a experienced programmer).

Here are some screenshots of when it works and when it doesn't, and the code (JS). The script is a simplified version of the one found in the Unity's Procedural Examples, and the Perlin Noise function can be found there too.

EDIT: CODE UPDATED, NOW WORKING, SEE UPDATE BELOW

alt text

alt text

 var scale : float = 1.0;
 var recalculateNormals = true;

 private var perlin : Perlin = new Perlin();
 
 function Start ()
 {
 for(var childPlane : Transform in transform) 
  MakePerlin(childPlane);
 }
 
 function MakePerlin(childPlane : Transform){

 var baseVertices : Vector3[];
 
 var mesh : Mesh = childPlane.GetComponent(MeshFilter).mesh;
  
 if (baseVertices == null)
 baseVertices = mesh.vertices;
  
 var vertices = new Vector3[baseVertices.Length];
  
 for (var i = 0; i < vertices.Length; i++)
 {
 var vertex = baseVertices[i];

 var worldPosition : Vector3 = childPlane.transform.TransformPoint(baseVertices[i]);
  
 vertex.y += perlin.Noise(worldPosition.x + 0.1, worldPosition.z + 0.1) * scale;
  
 vertices[i] = vertex;
 }
  
 mesh.vertices = vertices;
  
 if (recalculateNormals) 
 mesh.RecalculateNormals();
  
 mesh.RecalculateBounds();

 childPlane.GetComponent(MeshCollider).sharedMesh = null;
 childPlane.GetComponent(MeshCollider).sharedMesh = mesh;
 }

I don't know if my logic is flawed, but it seems to be almost there. Thanks in advance.

EDIT: SOLVED.

Solved. It was very simple: it was just a matter of converting each vertex coordinate (by default, in local space) to world space. Once we know each vertex world coordinates, the Perlin noise function can be applied to world space coordinates, so every vertex that shares that world space coordinate will have the same noise. Below, an image showing it. And the code has been updated too.

alt text

Just posted it so that if anyone comes across this question, it may be useful.

perlin_example_3.jpg (153.7 kB)
perlin_example_2.jpg (124.8 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

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Saitodepaula · Aug 10, 2012 at 05:30 PM

I don't know if I can answer my own question but I've come to a solution and just wanted to mark it as solved (look at the edits in the question itself).

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 DaveA · Feb 26, 2013 at 02:06 AM 1
Share

Sure. but usually, put the answer IN and answer. Glad you got it working.

avatar image
0

Answer by Fourthings · Feb 26, 2013 at 01:57 AM

That was quite useful, thank you!

Comment
Add comment · 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
0

Answer by herlon214 · Sep 16, 2021 at 08:55 PM

Indeed quite useful, thank you very much!

Comment
Add comment · 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

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

12 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

Related Questions

Basics of Perlin Noise? 1 Answer

easy c# Simplex Noise script code 1 Answer

Using noise as texture 2 Answers

Optimize perlin code 1 Answer

Why does Perlin-generated Texture lose gradient when with colour? 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