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 /
This question was closed Aug 19, 2013 at 12:43 AM by Negagames for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Negagames · Aug 18, 2013 at 05:11 PM · c#mathfperlinterrain gen

Seeding perlin functions

Simple question. Is there a way to seed the Mathf.PerlinNoise function?

Comment
Add comment · Show 4
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 robertbu · Aug 18, 2013 at 05:44 PM 0
Share

Typically you randomize the $$anonymous$$athf.PerlinNoise() by randomizing the offset where you start.

avatar image Negagames · Aug 18, 2013 at 06:19 PM 0
Share

But the question is if I can use a string like "banans" or "404" to create the randomization

avatar image robertbu · Aug 18, 2013 at 07:34 PM 1
Share

If you want to use a string, then you need to use some sort of function that maps a string into two semi-random floating point numbers. Then you can use the code @DaveA provided:

 using UnityEngine;
 using System.Collections;
 
 public class Bug20 : $$anonymous$$onoBehaviour {
     
 string input = "";
 Rect rect = new Rect(100,100,200,50);
         
     float Hash(string st, int prime) {
             int val = 0;
             for (int i = 0; i < st.Length; i++)
                 val = (val + st[i]) % prime;
             
             return (float)val/prime;
     }
     
     void Update() {
         Debug.Log (Hash (input, 263) + ", " + Hash(input, 193));
     }
         
     void OnGUI() {
         input = GUI.TextField(rect, input);    
 
     }
 }

The distribution of numbers returned by Hash() won't be great, but for what I think you are trying to do, it should work fine.

avatar image Negagames · Aug 18, 2013 at 11:15 PM 0
Share

^ Thank you!

1 Reply

  • Sort: 
avatar image
0

Answer by DaveA · Aug 18, 2013 at 06:28 PM

I don't think so but it's easy. Manual says: "The same coordinates will always return the same sample value but the plane is essentially infinite so it is easy to avoid repetition by choosing a random area to sample from." as robertu says too.

The code in the manual, you would set xOrg and yOrg to your 'seed'. Here's a way to randomize that.

 var xOrg: float = Random.value;
 var yOrg: float =  Random.value;
 var xCoord = xOrg + x / noiseTex.width * scale;
 var yCoord = yOrg + y / noiseTex.height * scale;
 var sample = Mathf.PerlinNoise(xCoord, yCoord);
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 Negagames · Aug 18, 2013 at 11:15 PM 0
Share

That's not really seeding.

Follow this Question

Answers Answers and Comments

16 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Object rotation using Mathf.Atan2 0 Answers

Trigonometry Unit Circle Question 1 Answer

Using Blend Trees, I want to switch smoothly based on input, but my input is simulated. How can I achieve this? 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