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 Otaku_Riisu · Jul 19, 2020 at 04:41 AM · mathperlin noiseterrain generationformulamarching cubes

Perlin Noise subtraction formula

I am currently trying to generate "Floating Island" style terrain using Perlin noise. I can get the terrain to render just fine, but am having trouble getting the terrain layout to be what I want. Here is a diagram of what I am trying to achieve:

alt text
In theory , this is what I want to do:
Obtain two perlin noise values, one "baseline" value, and one "intensified" value.
If the baseline value is greater than the intensified value, then we return the baseline value, otherwise we return zero.
This is the code I am currently using:

 private float PerlinSubtractor(int x, int z) {
     float returnVal = -1;

     float baseHeight = (float)height * Mathf.PerlinNoise((float)x / 16f * 1.5f + 0.001f, (float)z / 16f * 1.5f + 0.001f);
     float intensifiedHeight = (float)height * 1.2f * Mathf.PerlinNoise((float)x / 16f * 1.5f + 100.001f, (float)z / 16f * 1.5f + 100.001f);

     if (baseHeight > intensifiedHeight) returnVal = baseHeight;

     return returnVal;
 }


However that returns the following result: alt text

I dont understand why it goes straight down instead of tapering off. Am I passing incorrect values, or is my formula too intense? Any help or suggestions would be appreciated.

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 Bunny83 · Jul 19, 2020 at 10:35 AM 0
Share

Well, what exactly are you doing when you return a value of -1 ? Are you sure you don't actually use that value as a height value? A mesh never generates vertices on its own. You have to generate those vertices down there. So the issues has to be in your meshing code.

avatar image Otaku_Riisu Bunny83 · Jul 19, 2020 at 06:30 PM 0
Share

I think you may be right, I am returning it as a height value.

Right now, I am using this method to populate the terrain map:

         void PopulateTerrain$$anonymous$$ap() {
             for (int x = 0; x < width + 1; x++) {
                 for (int y = 0; y < height + 1; y++) {
                     for (int z = 0; z < width + 1; z++) {
                         terrain$$anonymous$$ap[x, y, z] = (float) y - PerlinSubtractor(x, z); ;
                     }
                 }
             }
         }

And this method parses the terrain map:

     void $$anonymous$$archCube(Vector3Int position) {
                 //position here is the position on the terrain map
         float[] cube = new float[8];
 
         for (int i = 0; i < 8; i++) {
             cube[i] = SampleTerrain(position + CornerTable[i]);
         }
             //This method gets which things to draw
         int configIndex = GetCubeConfiguration(cube);
             //I skip these two configurations because they represent air and underground, so no need to draw them.
         if (configIndex == 0 || configIndex == 255) {
             return;
         }
 
         int edgeIndex = 0;
         for (int i = 0; i < 5; i++) {
             for (int point = 0; point < 3; point++) {
                 int index = TriangleTable[configIndex, edgeIndex];
                 if (index == -1) return;
                             //this gets the data from the marching cubes tables I'm using
                 Vector3 vertex1 = position + CornerTable[EdgeIndexes[index, 0]];
                 Vector3 vertex2 = position + CornerTable[EdgeIndexes[index, 1]];
 
                 Vector3 vertexPosition = (vertex1 + vertex2) / 2;

                 vertices.Add(vertexPosition);
                 triangles.Add(vertices.Count - 1);
                 edgeIndex++;
             }
         }
     }

From here, I generate the terrain using the generated vertices and triangles.

I think this would generate a mesh as I'm trying, but clearly I've messed up somewhere. If youd like, you can view the whole script here

0 Replies

· Add your reply
  • Sort: 

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

143 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

Related Questions

How to efficiently shade a flat shaded mesh, smoothly. 1 Answer

Advice on 2D Surface Terrain Generation Using Noise 1 Answer

Voxel Terrain , Trees , Destruction - help please 0 Answers

Why does Perlin noise produce horizontal lines? 0 Answers

Distance in a Trajectory of a projectile 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