Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by takochako987 · Jul 12, 2018 at 05:01 AM · procedural generationperlin noisenoiseperlinperlinnoise

Perlin Noise generating as vertical lines instead of noise.

I'm following a series of tutorials on YouTube about how to procedurally generate terrain using Perlin Noise. Everything was going fine until I made a change (I don't remember what I changed though) and the "noise" started to render as vertical lines. I've been trying to debug this for two days now, but I don't have any prior experience with Perlin Noise, and my googling and research haven't brought me anything. I don't know if I'm just not searching for the right thing but it would really help if someone could tell me what I'm doing wrong. Here's what the image looks like right now. alt text

Here's the code for the noise generation script. using System; using System.Collections; using System.Collections.Generic; using UnityEngine;

 public static class Noise {
 
     public static float[,] GenerateNoiseMap(int mapWidth, int mapHeight, float scale, int octaves, float persistance, float lacunarity, int seed, Vector2 offset)
     {
         float[,] noiseMap = new float[mapWidth, mapHeight];
 
         System.Random prng = new System.Random (seed);
         Vector2[] octaveOffset = new Vector2[octaves];
         for (int i = 0; i < octaves; i++) {
             float offsetX = prng.Next(-50000, 50000) + offset.x;
             float offsetY = prng.Next(-50000, 50000) + offset.y;
             octaveOffset [i] = new Vector2 (offsetX, offsetY);
         }
 
         if (scale <= 0)
         {
             scale = 0.0001f;
         }
 
         float maxNoiseHeight = float.MinValue;
         float minNoiseHeight = float.MaxValue;
 
         float halfWidth = mapWidth / 2f;
         float halfHeight = mapHeight / 2f;
 
         for (int y = 0; y < mapHeight; y++) {
         
             for (int x = 0; x < mapWidth; x++) {
 
                 float amplitude = 1;
                 float frequency = 1;
                 float noiseHeight = 0;
             
                 for (int i = 0; i < octaves; i++) {
                     float sampleX = (x - halfWidth) / scale * frequency + octaveOffset[i].x;
                     float sampleY = (x - halfHeight) / scale * frequency + octaveOffset[i].y;
 
                     float perlinValue = Mathf.PerlinNoise (sampleX, sampleY) * 2 - 1;
                     noiseHeight += perlinValue * amplitude;
 
                     amplitude *= persistance;
                     frequency *= lacunarity;
                 }
 
                 if (noiseHeight > maxNoiseHeight) {
                     maxNoiseHeight = noiseHeight;
                 } else if (noiseHeight < minNoiseHeight) {
                     minNoiseHeight = noiseHeight;
                 }
                 noiseMap [x,y] = noiseHeight;
             }
         }
 
         for (int y = 0; y < mapHeight; y++) {
             for (int x = 0; x < mapWidth; x++) {
                 noiseMap [x,y] = Mathf.InverseLerp(minNoiseHeight, maxNoiseHeight, noiseMap [x,y]);
             }
         }
         return noiseMap;
     }
 }
 

Just let me know if you need any more information!

Comment
Add comment · Show 2
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 NoDumbQuestion · Jul 12, 2018 at 06:06 AM 0
Share

I didn't read the code but I know the offset for Y-axis are wrong.

avatar image takochako987 NoDumbQuestion · Jul 12, 2018 at 03:53 PM 0
Share

Do you know what I should change? Sorry, I'm kind of new to this. The offsets are both set to 0, but I don't know if that's what you mean.

1 Reply

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

Answer by takochako987 · Jul 13, 2018 at 04:56 PM

Nevermind I found it myself. It was a stupid typo. I accidentally typed x - halfHeight instead of y - halfHeight.

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

148 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 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 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 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 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 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 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 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 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

Procedural Mesh Generation with Mathf.PerlinNoise Creates Flat, Irregular Terrain 0 Answers

How can I get a probability from perlin noise? 0 Answers

Seamless Perlin Noise problem. SOLVED 0 Answers

Mesh collider only working on part of procedurally generated mesh 1 Answer

Creating ridged perlin noise 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