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 thenachotech1113 · Feb 19, 2015 at 12:01 AM · noiseperlin

How to use Mathf.PerlinNoise ?

Hello, for several projects now i have tried to use perlin noise with aboslutely no succes. I have searched everywhere on information, and tried hundreds of inputs(literaly). I have bveen unable to pinpoint what am i doing wrong. Here are two ways I have tried that seemed logical but did not work:

  • you pass two floats (any number) and it gives you the apropiate 0 - 1 value in that point of the texture.

  • you pass in two floats from 0 - 1 and it will retourn a 0 - 1 value of that spot.

the problem is regardless of what I input i always end up getting the same value on several spots. here is a bunch of stuff i am doing every time that might help pinpoint what is wrong:

  • use two for loops to get the values of a square area of the perlin noise. -im using an old pc but i am 99% sure that it is capable of this because when i left the y fixed at 0.5 and changed the x it gave me diferent values, also, though every time i get the same value on every sample, when i change the method i get diferent values.

idk what ell could i add. its driving me nuts and i have abandoned several projects because of this. thanks a lot to all of you.

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
Best Answer

Answer by DanSuperGP · Feb 19, 2015 at 12:24 AM

Try this, you'll notice that if length and width divider are 1 you'll get a uniform grey... but if you use other settings your noise will be different. You'll also notice that it's the same each time... which can be very useful. If you don't want it to be the same every time... generate two random values before the loop, and add it to the x and y positions fed into Mathf.PerlinNoise()

 using UnityEngine;
 using System.Collections;
 
 
 public class NoiseMaterial : MonoBehaviour {
 
     public Material noiseMat;
 
     public float lengthDivisor = 2.0f;
 
     public float widthDivisor = 2.0f;
 
     // Use this for initialization
     void Start () {
 
         Texture2D noiseTexture = new Texture2D(100,100);
 
         for(int i = 0; i < 100; i++)
         {
             for( int j = 0; j < 100; j++)
             {
                 float noisePixel = Mathf.PerlinNoise(((float) i)/lengthDivisor , ((float) j)/widthDivisor );
 
                 noiseTexture.SetPixel( i, j, new Color(noisePixel, noisePixel, noisePixel));
 
             }
 
         }
 
         noiseTexture.Apply();
 
         noiseMat.mainTexture = noiseTexture;
 
     
     
     }
     
     // Update is called once per frame
     void Update () {
     
 
 
     }
 }
 

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 thenachotech1113 · Feb 19, 2015 at 02:11 AM 1
Share

THAN$$anonymous$$S A LOT! finaly a simple explanation.

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

21 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

Related Questions

How to use Perlin Noise for waves 0 Answers

Help Perlin Noise for Cubes? 1 Answer

What's wrong with this code? Perlin Noise 0 Answers

Perlin Noise Issue 0 Answers

Perlin noise tutorials ? 2 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