Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 pinksheep8426 · Oct 16, 2016 at 09:22 AM · terrainprocedural generationterraindataperlin noiseperlinnoise

Why is perlin noise generating flat terrain?

I am trying to generate terrain using perlin noise however the terrain being generated is a plateau. The script I'm using is as follows:

 var xlength = 65.0;
 var ylength = 65.0;
 var scale = 4.1f;
 var heights = new float[xlength, ylength];
 function Start () {
     for (var i = 0; i < xlength; i++)
         for (var j = 0; j < ylength;j++)
             heights[i,j] = Mathf.PerlinNoise(Time.time * i / xlength * scale/1000,Time.time * j / ylength * scale/1000)*i*j;
     gameObject.GetComponent(Terrain).terrainData.SetHeights(0,0,heights);
 }  

Any help that could be given would be appreciated! :)

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 tanoshimi · Oct 16, 2016 at 10:15 AM

As documented, the inputs for Mathf.PerlinNoise should be between 0.0 and 1.0. Although you can supply higher values seemingly without trouble, only the fractional part is considered.

You haven't typed any of your variables but, from the look of it, xlength and ylength are doubles, scale is a float, i and j are integers. I think you are then always supplying a whole integer value as the parameters to PerlinNoise (they're certainly not in the range 0.0 - 1.0), which is why you're always getting the same output.

This is one of the many reasons Javascript is sometimes frowned upon - its lack of strict typecasting makes it far too easy to write code that doesn't do what you expect. I recommend you always explicitly declare a type for your variables, e.g.: var ylength : float = 65.0; (if you intended ylength to be a float) or var ylength : int = 65; (if you didn't), then you wouldn't accidentally end up doing integer math when you didn't expect it. And to solve your immediate problem, ensure you do your calculation only with floats.

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 PandaArcade · Jun 12, 2018 at 10:54 PM 0
Share

Where in the documentation does it state that the input should be between 0-1. The first example they give is between 0-10 (Perlin noise sampled in the range 0..10).

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Terrain and PerlinNoise Glitch 0 Answers

Unexpected period length with Unity Mathematics pnoise method 0 Answers

How can I correctly offset seeded perlin noise over multiple terrains? 1 Answer

I've written a script to create dynamic height maps. How do I use those height maps to generate dynamic procedural terrains? 1 Answer

Terrain Stitching 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