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 O-R-C · Apr 23, 2015 at 05:29 PM · proceduralprocedural-generationprocedural-terrain

How to add erosion to terrain on runtime

Hello, I have a script that generates random terrain, but I can not get the terrain to have erosion. Can someone show me how to achieve erosion like looks on a terrain.

Here is the code (It is not mine).

 private NoiseModule m_mountainNoise = new PerlinNoise(1);
     private NoiseModule m_plainsNoise = new PerlinNoise(1);
     private NoiseModule m_mountainNoiseRidged = new RidgedNoise(1);
 
     public TerrainPatch(int globTileX_i, int globTileZ_i, Terrain terrain_i, int h0_i, int h1_i, Vector3 pos_i)
     {
         globalTileX = globTileX_i;
         globalTileZ = globTileZ_i;
         terrain = terrain_i;
         h0 = h0_i;
         h1 = h1_i;
         pos = pos_i;
     }
 
     private int globalTileX, globalTileZ, h0, h1;
     private Vector3 pos;
     private Terrain terrain;
 
     public void ExecutePatch()
     {
         FillTerrainPatch();
         if (h1 == InfiniteTerrain.m_heightMapSize)
         {
             terrain.terrainData.SetHeights(0, 0, InfiniteTerrain.m_terrainHeights);  //SetHeights calculates terrain collider
             terrain.transform.position = pos;
         }
     }
      
     private void FillTerrainPatch()
     {
         int hRes = InfiniteTerrain.m_heightMapSize;
         float ratio = (float)InfiniteTerrain.m_landScapeSize / (float)hRes;
 
         float z0 = (InfiniteLandscape.initialGlobalIndex * (InfiniteTerrain.m_heightMapSize - 1)) * ratio;
         float z1 = (InfiniteLandscape.initialGlobalIndex * (InfiniteTerrain.m_heightMapSize - 1)) * ratio + hRes * ratio;
         float y0 = 0.0f;
         float y1 = 1.0f;
 
         for (int z = h0; z < h1; z++)
         {
             float worldPosZ = (z + globalTileZ * (InfiniteTerrain.m_heightMapSize - 1)) * ratio;
             float hx = Mathf.Clamp((y1 - y0) / (z1 - z0) * (worldPosZ - z0) + y1, -4, 8);
 
             for (int x = 0; x < hRes; x++)
             {
                 float worldPosX = (x + globalTileX * (InfiniteTerrain.m_heightMapSize - 1)) * ratio;
                 float mountainsPerlin = m_mountainNoise.FractalNoise2D(worldPosX, worldPosZ, 4, 3000, 0.4f);
                 float mountainsRidged = m_mountainNoiseRidged.FractalNoise2D(worldPosX, worldPosZ, 4, 3000, 0.2f);
                 float height = (mountainsRidged + mountainsPerlin) + 0.03f * hx;
                 InfiniteTerrain.m_terrainHeights[z, x] = height;
             }
         }
     }


What do I need to change to add in erosion?

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 $$anonymous$$ · Apr 23, 2015 at 06:57 PM 0
Share

What do you mean by erosion?

avatar image O-R-C · Apr 24, 2015 at 05:06 AM 0
Share

The terrain generated is very smooth. I want it to have water erosion on it, or just even have the surface bumped. Like this. alt text

The terrain here is not rolling hills, but rather it has an eroded surface.

terraintiles.jpg (244.6 kB)

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Procedural terrain bigger than I set it, heightmap slightly off 0 Answers

C# Proceducal Mesh terrain 2 Answers

Procedurally generated (Small)Universe 1 Answer

Proper use of threads with procedural generation 1 Answer

For loop not starting from zero 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