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 Zionviller · May 25, 2013 at 01:52 AM · perlin noisenoiseperlin

Always same result from Mathf.PerlinNoise()

Hi,

I'm having some trouble using the Perlin Noise generator.

 using UnityEngine;
 using System.Collections;
 
 public class PerlinTest : MonoBehaviour {
     private float inNum;
     
     // Use this for initialization
     void Start () {
         inNum = 0.0f;
     }
     
     // Update is called once per frame
     void Update () {
         Debug.Log(inNum + ": " + Mathf.PerlinNoise(inNum,0.0f));
         inNum = inNum + 100.0f;
     }
 }

I keep getting the same number. What am I doing wrong? Thanks!

Comment
Add comment · Show 3
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 MikeNewall · May 25, 2013 at 01:58 AM 0
Share

http://answers.unity3d.com/questions/188721/creating-perlin-noise.html

Take a look at this

avatar image Zionviller · May 25, 2013 at 02:07 AM 0
Share

I looked at that and, as far as I can tell, I'm using it in the same way. But I'm probably missing something. I was hoping a second (or third, fourth, or fifth) pair of eyes could help me spot what's wrong.

avatar image fabriciopsyko · Jun 02, 2015 at 09:16 AM 0
Share

I was having this same problem with same results with this: public int groundPerlinNoise (int x, int z){ float noise = $$anonymous$$athf.PerlinNoise(x/ground$$anonymous$$aturity, z/ground$$anonymous$$aturity); noise*=groundVarience; noise+=groundHeight; return (int)noise; } I changed the type "int" to "float" for the args, like this: public int groundPerlinNoise (float x, float z){ float noise = $$anonymous$$athf.PerlinNoise(x/ground$$anonymous$$aturity, z/ground$$anonymous$$aturity); noise*=groundVarience; noise+=groundHeight; return (int)noise; }

2 Replies

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

Answer by robertbu · May 25, 2013 at 02:21 AM

Change line 15 to the following:

 inNum = inNum + 0.01f;

I ran into this problem the first time I used PerlinNoise(). It appears that the results are mod 1.0. So you will have this issue if you use 1.0 or 100.0. But change the numbers to 1.01 or 100.1 and you will not longer get a repeating number. But such large numbers will not give you the smooth transitions either.

Comment
Add comment · Show 2 · 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 Zionviller · May 25, 2013 at 02:23 AM 0
Share

Yep! That did it! Thanks a bunch!

avatar image Tubusus · May 30 at 06:09 PM 0
Share

Just a minor correction, it's not mod 1 (which would imply the noise repeats every unit), but rather the returned value is the baseline value (theoretically it should be the median value, but that's not quite the case with Unity Perlin, at least not in my case as I detail in https://answers.unity.com/questions/1904122/unity-perlin-noise-value-distributiondistribution.html

  • if anyone reading this could test it for themselves that would be great, there should be an update where I found out this value to be 0.4652731) at integer coordinates. This isn't specific for Unity but is common to all Perlin noise implementations.

Also changing the number you add to inNum every update will change the scale (or in this case speed) of the noise, smaller increment means slower change.

avatar image
0

Answer by JohnDoe20001 · May 17, 2016 at 01:00 PM

The Perlin Noise is getting value starting at the same point each time. The function is a string of the wave based values. So you are going to end up traversing the same landscape every time.

So you need to seed the function to force it to start ad different point.

 using UnityEngine;
 using System.Collections;
 
 public class PerlinTest : MonoBehaviour {
     private float inNum;
     private int seed = (int)Network.time * 10;
 
     // Use this for initialization
     void Start () {
         inNum = 0.0f;
     }
 
     // Update is called once per frame
     void Update () {
         Debug.Log(inNum + ": " + Mathf.PerlinNoise(inNum + seed,0.0f));
         inNum = inNum + 100.0f;
     }
 }

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

17 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

Related Questions

3D Perlin Noise mesh even in all axes 1 Answer

Unity Perlin Noise Bug? 3 Answers

How to use Perlin Noise for waves 0 Answers

Perlin noise problem 0 Answers

Basics of Perlin Noise? 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