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 MrIntel · Jan 09, 2015 at 11:48 PM · terrainterrains

Perlin Terrain Generation?

I'm having trouble finding a tutorial on this but would i use Perlin noise or any other noise function to generate a terrain mesh?

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

2 Replies

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

Answer by grahnzz · Jan 10, 2015 at 03:45 AM

http://lmgtfy.com/?q=perlin+noise+unity+terrain

There's a lot of resources on this on the web. But perlin noise or any other coherent noise function is nothing more than a random number generator that produces values that can be predicted assuming you are using the same parameters, that is why for example minecraft can build the same level for you using just one integer as the seed.

This noise can then be applied to a mesh, typically this would be done along the world Y-axis only. If you want to use the unity Terrain system for a more performant solution that should be possible too; by applying the noise to a heightmap, i'm not sure how you would do this at runtime though. I have a feeling that unity's terrain system isn't designed to update its mesh dynamically.

I will leave you with some code from http://docs.unity3d.com/ScriptReference/Mesh.html

 using UnityEngine;
 using System.Collections;
 
 public class ExampleClass : MonoBehaviour {
     void Update() {
         Mesh mesh = GetComponent<MeshFilter>().mesh;
         Vector3[] vertices = mesh.vertices;
         Vector3[] normals = mesh.normals;
         int i = 0;
         while (i < vertices.Length) {
             vertices[i] += normals[i] * Mathf.Sin(Time.time);
             i++;
         }
         mesh.vertices = vertices;
     }
 }

this code goes through all vertices in the mesh and extrudes them along the normal of the vertex by a multiplier of Mathf.Sin(). Try swapping that Mathf.Sin() with a Mathf.PerlinNoise(vertices[i].x, vertices[i].y)

If you like the idea of procedurally building your terrain, but the terrain doesn't need to be built during the runtime of your game. Take a look @ http://www.world-machine.com/ World machine is a tool that helps you build terrain with the help of noise nodes and other mathematical functions

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 MrIntel · Jan 10, 2015 at 05:09 AM 0
Share

thank you i should have clarified though i wasnt actually trying to generate terrain a t runtime or flat terrain for that matter but planetary terrain so i can make random planets i just didnt know how to manipulate the verts.

avatar image
0

Answer by Ericool · Jan 10, 2015 at 03:39 AM

Or you could find a texture generated by Perlin Noise look for extension raw and the kind of texture is a terrain heightmap. So then use the terrain editor to generate it for you it is easier than generating yourself the terrain with an algorithm that is already known . Also your terrain wont be different than if I use the terrain editor. Just saying if you want to save some time. Good Luck.

But if you really want to do it , how it works it that the intensity of a pixel(in the texture) is the height ratio of a vertex or a block of vertices. So you would have to do a double for loop and adding a vertices at location [i][j] and the vertices[i][j].position = GetPixel().alpha * 10.0f; Something like that for sure. Once the mesh is done you must save it as an asset. Using SaveAssets().

A year or two ago I have done a terain mesh in c++ and it takes time..but the algorithm is easy.

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.

Follow this Question

Answers Answers and Comments

27 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

Related Questions

help with terrains 1 Answer

Unity Terrain looking strange and dark 0 Answers

Access terrains "Alphamap 0" from within code 0 Answers

Terrain Collider doesn't update/ how to create a new terrain Collider? 2 Answers

Multiple terrain with different values 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