• 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 Aldon0 · Nov 16, 2017 at 08:11 PM · terrainterrain generationterrain-editorterrain gen

Something wrong with how i handle terrain generation

I'm working on a procedural terrain generator. At it's core, my script goes through each point in the height map and assigns it a 1 or a 0 (50/50 chance) I then use this noise to generate an organic looking map, which based on the height, either does or doesn't peek over a "water" plane.

my problem is this: depending on the general direction the "coasts" are running, the height either appears as "smooth" (using 45 degree angles) or "stepped" (only traveling at a series of 90 degree angles.)

The image I provide is after a few iterations of my function that makes it look more organic. this issue shows up entirely at the random noise part, so i'm just providing this image to make the problem more clear.

alt text

"coasts" with a positive slope act like 2

"coasts" with a negative slope behave like 1.

I want the "coasts" to behave like example 2.

Anyone have any idea why the terrain is behaving like this?

The following code is how i generate my noise.

     void GenerateNoise()
     {
         for (int x = 1; x < Dx - 1; x++) {
             for (int y = 1; y < Dy - 1; y++)
             {
                 //give each point a 0 or 1
                 map1[x, y] = Random.Range(0, 2);
             }
         }
     }

     void ConvertMap(){
         //convert the int map in to a float map for heights
         for (int x = 0; x < Dx; x++)
         {
             for (int y = 0; y < Dy; y++)
             {
                 map3[x, y] = (float)map1[x, y] / 30.0f;
             }
         }
     }
 
     void PrintMap()
     {
         ConvertMap(); 
         ground.terrainData.SetHeights(0, 0, map3);
     }

sorry If this is confusing, trying to explain it as clearly as I can. Please let me know how I can clarify. THANKS!

terrainissue.jpg (162.9 kB)
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

Answer by Bunny83 · Nov 17, 2017 at 04:19 AM

Well you do "hard edges" in your terrain so you actually see the individual "Quads". Have a look at this figure:

 P0 ----- P1
  |      / |
  |    /   |
  |  /     |
  |/       |
 P2 ----- P3


Imagine all points are "high" except one. If P2 or P1 are low your quad becomes a concave mesh. So there will be a notch along the diagonal. However if you lower only P0 or P3 you get a convex mesh where the diagonal between P1 and P2 "stays" top. So in this case you actually get one triangle that is flat and one that is slanted downwards. However in the first case both triangles would be slanted.


Is this actually a 3d game? If not using the terrain seems a bit overkill.

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 Aldon0 · Nov 17, 2017 at 07:49 PM 0
Share

Thanks @Bunny83 , that makes sense, and yes, eventually it will be played first person (I'm going for a lo-fi feel) I'm guessing this will be a limitation of the unity terrain, i.e. maybe I should build my own?

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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

88 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

Related Questions

I want to create a 3D World. 1 Answer

Applying a Large Texture Map to a Terrain 1 Answer

Process heavy issues 0 Answers

Procedural terrain generation - What exactly does Terrain.Flush() do? 0 Answers

Terrain Issue [Video] 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges