• 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 Antao98 · Apr 01, 2018 at 11:23 PM · proceduralgenerationperlin noiseprocedural texturing

Is it possible to round a perlin noise value to 1 or 0?

Is it possible to round a perlin noise value to 1 or 0? What I mean is, if perlin noise floats between 0 and 1, how can I round the values bigger than 0.50 to 1 and the values smaller than 0.50 to 0. I'm making a texture and I already have perlin noise generating it, but what I'm looking for is a 0 or 1 system.

Comment
Add comment · Show 1
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 Antao98 · Apr 02, 2018 at 10:48 PM 0
Share

Even though no one is answering I'm still gonna give updates. I've made a new script, but with basic noise, not with perlin noise.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class SimplexNoise : $$anonymous$$onoBehaviour {
 
     float xCoord, yCoord;
     public int width, height;
     public GameObject rockTile;
     float noise;
     Vector3 pos;
 
     // Use this for initialization
     void Start () {
         GenerateTerrain ();
     }
         
     void GenerateTerrain()
     {
         for (xCoord = 0; xCoord < width; xCoord++) {
             for (yCoord = 0; yCoord < height; yCoord++) {
                 noise = Random.value;
                 pos = new Vector3 (xCoord, yCoord, 0);
                 if(noise < 0.5f)
                 {
                     noise = 0;
                 }
                 else{
                     noise = 1;
                     Instantiate (rockTile, pos, Quaternion.identity);
                 }
             }
         }
     }
 }


Basically it does what I want, but I'm ending with a basic white noise "texture".

Note: If you try this start with the width and height at 10, then increase it accordingly to your machine, because it will crash unity.

1 Reply

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

Answer by Eno-Khaon · Apr 03, 2018 at 12:21 AM

Unity's Perlin Noise function takes a Vector2 as input and returns a float value, so I don't see any reason why you wouldn't be able to simply Round the result of it.

 float totalWidth = 50.0f; // example Width
 float totalHeight = 50.0f; // example Height
 
 for(int y = 0; y < totalHeight; y++)
 {
     float fy = y / totalHeight;
     for(int x = 0; x < totalWidth; x++)
     {
         float fx = x / totalWidth;
         float sample = Mathf.PerlinNoise(fx, fy);
         sample = Mathf.Round(sample);
     }
 }
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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

81 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

Related Questions

3d Perlin Noise? 3 Answers

Which is the best option (Procedurally world generation save) 1 Answer

2D Procedural Terrain Generation 1 Answer

Best way to procedurally generate materials with text 0 Answers

Optimized Noise Generation 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