Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
1
Question by Zaphyk · Feb 23, 2014 at 02:23 AM · 3dvoxelperlin noiselibnoise

LibNoise, How to use it?

Okay, so I was trying to make a Procedually generated voxel terrain. So yesterday i found this library which i tried to implement but,I couldnt, If anyone could explain me on how to implement it or has a better way to complete my goal. I will thank them very much.

Any pointers, links, a base code to start off, or simple information is useful

Thank you

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 AlucardJay · Jun 29, 2014 at 06:29 AM 0
Share

For what you want to do, first explore using Unitys 2D PerlinNoise. Using just a single pass or a 2-pass sample, you can make interesting terrain, higher levels of detail would be lost and wasted processor power for a voxel terrain.

I strongly recommend this tutorial series for generating voxel terrain. This part introduces PerlinNoise.

I shall leave an answer for anyone looking how to use the LibNoise library, but for your application my above suggestions should get you on the way to some amazing results anyway.

3 Replies

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

Answer by AlucardJay · Jun 29, 2014 at 06:42 AM

For future readers who find this question and want to use the LibNoise library for Unity, I have written C# scripts for the tutorial series on the LibNoise official 'site.

First step would be to grab the LibNoise library. I have posted a comment with the package I used when writing these scripts.

Follow the guide on the LibNoise site, then look at the code I have written. This shall hopefully give insight on how to use these classes for yourself.

For each script, I used a cube placed in the scene. When the noise is calculated, it generates a Texture2D which is applied to the cube renderer for an immediate visual output. Parameters can be modified in the inspector while playing the scene, then Left-Clicking in the scene window will update the texture and show on the cube.


Tutorial 3: Generating and rendering a terrain height map

 //------------------------------//
 //  Tutorial_3.cs               //
 //  Written by Alucard Jay      //
 //  2014/6/29                   //
 //------------------------------//
 
 //  http://libnoise.sourceforge.net/tutorials/tutorial3.html
 
 
 using UnityEngine;
 using System.Collections;
 
 using LibNoise.Unity;
 using LibNoise.Unity.Generator;
 using LibNoise.Unity.Operator;
 
 
 public class Tutorial_3 : MonoBehaviour 
 {
     public int mapSizeX = 256; // for heightmaps, this would be 2^n +1
     public int mapSizeY = 256; // for heightmaps, this would be 2^n +1
     
     public float sampleSizeX = 4.0f; // perlin sample size
     public float sampleSizeY = 4.0f; // perlin sample size
     
     public float sampleOffsetX = 2.0f; // to tile, add size to the offset. eg, next tile across would be 6.0f
     public float sampleOffsetY = 1.0f; // to tile, add size to the offset. eg, next tile up would be 5.0f
 
 
     public Renderer cubeRenderer; // renderer texture set for testing
 
     private Texture2D texture; // texture created for testing
     
     
     //  Persistant Functions
     //    ----------------------------------------------------------------------------
     
 
     void Start() 
     {
         Generate();
     }
     
     
     void Update() 
     {
         if ( Input.GetMouseButtonDown(0) )
             Generate();
     }
     
     
     //  Other Functions
     //    ----------------------------------------------------------------------------
     
     
     void Generate() 
     {
         Perlin myPerlin = new Perlin();
 
         ModuleBase myModule = myPerlin;
 
 
 
         // ------------------------------------------------------------------------------------------
         
         // - Generate -
         
         // this part generates the heightmap to a texture, 
         // and sets the renderer material texture of a cube to the generated texture
         
         
         Noise2D heightMap;
 
         heightMap = new Noise2D( mapSizeX, mapSizeY, myModule );
 
         heightMap.GeneratePlanar(
             sampleOffsetX,
             sampleOffsetX + sampleSizeX,
             sampleOffsetY,
             sampleOffsetY + sampleSizeY
             );
 
         texture = heightMap.GetTexture(GradientPresets.Grayscale);
 
         cubeRenderer.material.mainTexture = texture;
     }
 }


Tutorial 4: Modifying the parameters of the noise module

 //------------------------------//
 //  Tutorial_4.cs               //
 //  Written by Alucard Jay      //
 //  2014/6/29                   //
 //------------------------------//
 
 //  http://libnoise.sourceforge.net/tutorials/tutorial4.html
 
 
 using UnityEngine;
 using System.Collections;
 
 using LibNoise.Unity;
 using LibNoise.Unity.Generator;
 using LibNoise.Unity.Operator;
 
 
 public class Tutorial_4 : MonoBehaviour 
 {
     public int mapSizeX = 256; // for heightmaps, this would be 2^n +1
     public int mapSizeY = 256; // for heightmaps, this would be 2^n +1
     
     public float sampleSizeX = 4.0f; // perlin sample size
     public float sampleSizeY = 4.0f; // perlin sample size
     
     public float sampleOffsetX = 2.0f; // to tile, add size to the offset. eg, next tile across would be 6.0f
     public float sampleOffsetY = 1.0f; // to tile, add size to the offset. eg, next tile up would be 5.0f
     
     public int octaves = 6;
 
     public float frequency = 1.0f;
     
     public float persistence = 0.5f;
 
 
     public Renderer cubeRenderer; // renderer texture set for testing
     
     private Texture2D texture; // texture created for testing
     
     
     //  Persistant Functions
     //    ----------------------------------------------------------------------------
     
     
     void Start() 
     {
         Generate();
     }
     
     
     void Update() 
     {
         if ( Input.GetMouseButtonDown(0) )
             Generate();
     }
     
     
     //  Other Functions
     //    ----------------------------------------------------------------------------
     
     
     void Generate() 
     {
         Perlin myPerlin = new Perlin();
 
         // modify the number of octaves
         myPerlin.OctaveCount = octaves;
 
         // modify the frequency
         myPerlin.Frequency = frequency;
         
         // modify the persistence
         myPerlin.Persistence = persistence;
 
 
         ModuleBase myModule;
         
         myModule = myPerlin;
 
 
 
         // ------------------------------------------------------------------------------------------
         
         // - Generate -
         
         // this part generates the heightmap to a texture, 
         // and sets the renderer material texture of a cube to the generated texture
 
 
         Noise2D heightMap;
 
         heightMap = new Noise2D( mapSizeX, mapSizeY, myModule );
 
         heightMap.GeneratePlanar(
             sampleOffsetX,
             sampleOffsetX + sampleSizeX,
             sampleOffsetY,
             sampleOffsetY + sampleSizeY
             );
 
         texture = heightMap.GetTexture( GradientPresets.Grayscale );
 
         cubeRenderer.material.mainTexture = texture;
     }
 }


Tutorial 5: Generating more complex terrain

 //------------------------------//
 //  Tutorial_5.cs               //
 //  Written by Alucard Jay      //
 //  2014/6/29                   //
 //------------------------------//
 
 //  http://libnoise.sourceforge.net/tutorials/tutorial5.html
 
 
 using UnityEngine;
 using System.Collections;
 
 using LibNoise.Unity;
 using LibNoise.Unity.Generator;
 using LibNoise.Unity.Operator;
 
 
 public class Tutorial_5 : MonoBehaviour 
 {
     public int mapSizeX = 256; // for heightmaps, this would be 2^n +1
     public int mapSizeY = 256; // for heightmaps, this would be 2^n +1
     
     public float sampleSizeX = 4.0f; // perlin sample size
     public float sampleSizeY = 4.0f; // perlin sample size
     
     public float sampleOffsetX = 6.0f; // to tile, add size to the offset. eg, next tile across would be 6.0f
     public float sampleOffsetY = 1.0f; // to tile, add size to the offset. eg, next tile up would be 5.0f
 
 
     public Renderer cubeRenderer; // renderer texture set for testing
     
     private Texture2D texture; // texture created for testing
 
 
     //  Persistant Functions
     //    ----------------------------------------------------------------------------
     
     
     void Start() 
     {
         Generate();
     }
     
     
     void Update() 
     {
         if ( Input.GetMouseButtonDown(0) )
             Generate();
     }
     
     
     //  Other Functions
     //    ----------------------------------------------------------------------------
     
     
     public float baseflatFrequency = 2.0f;
     
     public float flatScale = 0.125f;
     public float flatBias = -0.75f;
     
     public float terraintypeFrequency = 0.5f;
     public float terraintypePersistence = 0.25f;
 
     public float finalTerrainEdgeFalloff = 0.125f;
 
     
     void Generate() 
     {
         // - Mountain Terrain -
 
         //module::RidgedMulti mountainTerrain;
 
         RidgedMultifractal mountainTerrain = new RidgedMultifractal();
 
 
 
         // - Base Flat Terrain -
 
         //module::Billow baseFlatTerrain;
         //baseFlatTerrain.SetFrequency (2.0);
         
         Billow baseFlatTerrain = new Billow();
 
         baseFlatTerrain.Frequency = baseflatFrequency;
 
 
 
         // - Flat Terrain -
         
         //module::ScaleBias flatTerrain;
         //flatTerrain.SetSourceModule( 0, baseFlatTerrain );
         //flatTerrain.SetScale (0.125);
         //flatTerrain.SetBias (-0.75);
         
         ScaleBias flatTerrain = new ScaleBias( flatScale, flatBias, baseFlatTerrain ); // scale, bias, input
         
         
         
         // - Terrain Type -
 
         //module::Perlin terrainType;
         //terrainType.SetFrequency (0.5);
         //terrainType.SetPersistence (0.25);
 
         Perlin terrainType = new Perlin();
 
         terrainType.Frequency = terraintypeFrequency;
         terrainType.Persistence = terraintypePersistence;
         
         
         
         // - Final Terrain -
 
         //module::Select finalTerrain;
         //finalTerrain.SetSourceModule (0, flatTerrain);
         //finalTerrain.SetSourceModule (1, mountainTerrain);
 
         Select finalTerrain = new Select( flatTerrain, mountainTerrain, terrainType ); // input A, input B, Controller
 
 
         // finalTerrain.SetBounds (0.0, 1000.0);
         finalTerrain.SetBounds( 0.0, 1000.0 );
 
         //finalTerrain.SetEdgeFalloff (0.125);
         finalTerrain.FallOff = finalTerrainEdgeFalloff;
 
 
 
         // ------------------------------------------------------------------------------------------
         
         // - Compiled Terrain -
 
         ModuleBase myModule;
 
         // each of these are used in each chapter after the above variables are declared and assigned
         //myModule = mountainTerrain; // testing base flat terrain (Generating the rough mountainous terrain)
         //myModule = baseFlatTerrain; // testing base flat terrain (Generating the base values for the flat terrain)
         //myModule = flatTerrain; // testing flat terrain (Generating the flat terrain)
         //myModule = terrainType; // testing terrain type (Generating the terrain-type map)
         myModule = finalTerrain; // testing final terrain (Generating the final terrain)
 
 
 
         // ------------------------------------------------------------------------------------------
 
         // - Generate -
 
         // this part generates the heightmap to a texture, 
         // and sets the renderer material texture of a cube to the generated texture
         // (this part never changes, always here since the start of the tutorial page) 
         // (only myModule changes, so this part remains the same)
 
         
         Noise2D heightMap;
         
         heightMap = new Noise2D( mapSizeX, mapSizeY, myModule );
         
         heightMap.GeneratePlanar(
             sampleOffsetX,
             sampleOffsetX + sampleSizeX,
             sampleOffsetY,
             sampleOffsetY + sampleSizeY
             );
         
         texture = heightMap.GetTexture(GradientPresets.Grayscale);
         
         cubeRenderer.material.mainTexture = texture;
     }
 }


Tutorial 6: Adding realism with turbulence

 //------------------------------//
 //  Tutorial_6.cs               //
 //  Written by Alucard Jay      //
 //  2014/6/29                   //
 //------------------------------//
 
 //  http://libnoise.sourceforge.net/tutorials/tutorial6.html
 
 
 using UnityEngine;
 using System.Collections;
 
 using LibNoise.Unity;
 using LibNoise.Unity.Generator;
 using LibNoise.Unity.Operator;
 
 
 public class Tutorial_6 : MonoBehaviour 
 {
     public int mapSizeX = 256; // for heightmaps, this would be 2^n +1
     public int mapSizeY = 256; // for heightmaps, this would be 2^n +1
     
     public float sampleSizeX = 4.0f; // perlin sample size
     public float sampleSizeY = 4.0f; // perlin sample size
     
     public float sampleOffsetX = 6.0f; // to tile, add size to the offset. eg, next tile across would be 6.0f
     public float sampleOffsetY = 1.0f; // to tile, add size to the offset. eg, next tile up would be 5.0f
 
 
     public Renderer cubeRenderer; // renderer texture set for testing
     
     private Texture2D texture; // texture created for testing
 
 
     //  Persistant Functions
     //    ----------------------------------------------------------------------------
     
     
     void Start() 
     {
         Generate();
     }
     
     
     void Update() 
     {
         if ( Input.GetMouseButtonDown(0) )
             Generate();
     }
     
     
     //  Other Functions
     //    ----------------------------------------------------------------------------
     
     
     public float baseflatFrequency = 2.0f;
     
     public float flatScale = 0.125f;
     public float flatBias = -0.75f;
     
     public float terraintypeFrequency = 0.5f;
     public float terraintypePersistence = 0.25f;
 
     public float terrainSelectorEdgeFalloff = 0.125f;
     
     public float finalterrainFrequency = 4.0f;
     public float finalterrainPower = 0.125f;
 
     
     void Generate() 
     {
         // - Mountain Terrain -
 
         //module::RidgedMulti mountainTerrain;
 
         RidgedMultifractal mountainTerrain = new RidgedMultifractal();
 
 
 
         // - Base Flat Terrain -
 
         //module::Billow baseFlatTerrain;
         //baseFlatTerrain.SetFrequency (2.0);
         
         Billow baseFlatTerrain = new Billow();
 
         baseFlatTerrain.Frequency = baseflatFrequency;
 
 
 
         // - Flat Terrain -
         
         //module::ScaleBias flatTerrain;
         //flatTerrain.SetSourceModule( 0, baseFlatTerrain );
         //flatTerrain.SetScale (0.125);
         //flatTerrain.SetBias (-0.75);
         
         ScaleBias flatTerrain = new ScaleBias( flatScale, flatBias, baseFlatTerrain ); // scale, bias, input
         
         
         
         // - Terrain Type -
 
         //module::Perlin terrainType;
         //terrainType.SetFrequency (0.5);
         //terrainType.SetPersistence (0.25);
 
         Perlin terrainType = new Perlin();
 
         terrainType.Frequency = terraintypeFrequency;
         terrainType.Persistence = terraintypePersistence;
         
         
         
         // - Terrain Selector -
 
         //module::Select terrainSelector;
         //terrainSelector.SetSourceModule (0, flatTerrain);
         //terrainSelector.SetSourceModule (1, mountainTerrain);
 
         Select terrainSelector = new Select( flatTerrain, mountainTerrain, terrainType ); // input A, input B, Controller
 
 
         // terrainSelector.SetBounds (0.0, 1000.0);
         terrainSelector.SetBounds( 0.0, 1000.0 );
 
         //terrainSelector.SetEdgeFalloff (0.125);
         terrainSelector.FallOff = terrainSelectorEdgeFalloff;
         
         
         
         // - Final Terrain -
 
         //module::Turbulence finalTerrain;
         //finalTerrain.SetSourceModule (0, terrainSelector);
 
         Turbulence finalTerrain = new Turbulence( terrainSelector );
         
         //finalTerrain.SetFrequency (4.0);
         finalTerrain.Frequency = finalterrainFrequency;
         
         //finalTerrain.SetPower (0.125);
         finalTerrain.Power = finalterrainPower;
 
 
 
 
         // ------------------------------------------------------------------------------------------
         
         // - Compiled Terrain -
 
         ModuleBase myModule;
 
         myModule = finalTerrain;
 
 
 
         // ------------------------------------------------------------------------------------------
 
         // - Generate -
 
         // this part generates the heightmap to a texture, 
         // and sets the renderer material texture of a cube to the generated texture
 
         
         Noise2D heightMap;
         
         heightMap = new Noise2D( mapSizeX, mapSizeY, myModule );
         
         heightMap.GeneratePlanar(
             sampleOffsetX,
             sampleOffsetX + sampleSizeX,
             sampleOffsetY,
             sampleOffsetY + sampleSizeY
             );
         
         texture = heightMap.GetTexture(GradientPresets.Grayscale);
         
         cubeRenderer.material.mainTexture = texture;
     }
 }


Tutorial 7 : Using the data and applying it to terrain data heights

This is not part of the series, but something I wrote to demonstrate how to get the height data and apply it to a terrain.

 //------------------------------//
 //  Tutorial_7.cs               //
 //  Written by Alucard Jay      //
 //  2014/6/29                   //
 //------------------------------//
 
 //  using information from data to apply to terrain heightmap
 
 
 using UnityEngine;
 using System.Collections;
 
 using LibNoise.Unity;
 using LibNoise.Unity.Generator;
 using LibNoise.Unity.Operator;
 
 
 public class Tutorial_7 : MonoBehaviour 
 {
     public int mapSizeX = 513; // for heightmaps, this would be 2^n +1
     public int mapSizeY = 513; // for heightmaps, this would be 2^n +1
     
     public float sampleSizeX = 4.0f; // perlin sample size
     public float sampleSizeY = 4.0f; // perlin sample size
     
     public float sampleOffsetX = 6.0f; // to tile, add size to the offset. eg, next tile across would be 6.0f
     public float sampleOffsetY = 1.0f; // to tile, add size to the offset. eg, next tile up would be 5.0f
 
 
     public Terrain terrain; // terrain to apply values to heightmap
 
 
     //  Persistant Functions
     //    ----------------------------------------------------------------------------
     
     
     void Start() 
     {
         Generate();
     }
     
     
     void Update() 
     {
         if ( Input.GetMouseButtonDown(0) )
             Generate();
     }
     
     
     //  Other Functions
     //    ----------------------------------------------------------------------------
     
     
     public float baseflatFrequency = 2.0f;
     
     public float flatScale = 0.125f;
     public float flatBias = -0.75f;
     
     public float terraintypeFrequency = 0.5f;
     public float terraintypePersistence = 0.25f;
 
     public float terrainSelectorEdgeFalloff = 0.125f;
     
     public float finalterrainFrequency = 4.0f;
     public float finalterrainPower = 0.125f;
 
     
     void Generate() 
     {
         // - Mountain Terrain -
 
         //module::RidgedMulti mountainTerrain;
 
         RidgedMultifractal mountainTerrain = new RidgedMultifractal();
 
 
 
         // - Base Flat Terrain -
 
         //module::Billow baseFlatTerrain;
         //baseFlatTerrain.SetFrequency (2.0);
         
         Billow baseFlatTerrain = new Billow();
 
         baseFlatTerrain.Frequency = baseflatFrequency;
 
 
 
         // - Flat Terrain -
         
         //module::ScaleBias flatTerrain;
         //flatTerrain.SetSourceModule( 0, baseFlatTerrain );
         //flatTerrain.SetScale (0.125);
         //flatTerrain.SetBias (-0.75);
         
         ScaleBias flatTerrain = new ScaleBias( flatScale, flatBias, baseFlatTerrain ); // scale, bias, input
         
         
         
         // - Terrain Type -
 
         //module::Perlin terrainType;
         //terrainType.SetFrequency (0.5);
         //terrainType.SetPersistence (0.25);
 
         Perlin terrainType = new Perlin();
 
         terrainType.Frequency = terraintypeFrequency;
         terrainType.Persistence = terraintypePersistence;
         
         
         
         // - Terrain Selector -
 
         //module::Select terrainSelector;
         //terrainSelector.SetSourceModule (0, flatTerrain);
         //terrainSelector.SetSourceModule (1, mountainTerrain);
 
         Select terrainSelector = new Select( flatTerrain, mountainTerrain, terrainType ); // input A, input B, Controller
 
 
         // terrainSelector.SetBounds (0.0, 1000.0);
         terrainSelector.SetBounds( 0.0, 1000.0 );
 
         //terrainSelector.SetEdgeFalloff (0.125);
         terrainSelector.FallOff = terrainSelectorEdgeFalloff;
         
         
         
         // - Final Terrain -
 
         //module::Turbulence finalTerrain;
         //finalTerrain.SetSourceModule (0, terrainSelector);
 
         Turbulence finalTerrain = new Turbulence( terrainSelector );
         
         //finalTerrain.SetFrequency (4.0);
         finalTerrain.Frequency = finalterrainFrequency;
         
         //finalTerrain.SetPower (0.125);
         finalTerrain.Power = finalterrainPower;
 
 
 
 
         // ------------------------------------------------------------------------------------------
         
         // - Compiled Terrain -
 
         ModuleBase myModule;
 
         myModule = finalTerrain;
 
 
 
         // ------------------------------------------------------------------------------------------
 
         // - Generate -
 
 
         Noise2D heightMap = new Noise2D( mapSizeX, mapSizeY, myModule );
         
         heightMap.GeneratePlanar(
             sampleOffsetX,
             sampleOffsetX + sampleSizeX,
             sampleOffsetY,
             sampleOffsetY + sampleSizeY
             );
 
         // both of these will return normalized values
         //float[,] heights = heightMap.GetData( true, 0, 0, true );
         float[,] heights = heightMap.GetNormalizedData( true, 0, 0 );
         
         // NOTE :
         // terrainData HeightMapData is actually [ y, x ]
         // so tiling is done in the Z-axis for X, and X-axis for Y
         // you could loop through x and y of heights
         // and return correctly sorted values using
         // heights[ y, x ] = heightMap[ x, y, true ];
 
 
         TerrainData terrainData = terrain.terrainData;
 
         terrainData.SetHeights( 0, 0, heights );
     }
 }


Tutorial 8: Creating spherical planetary terrain

For this one, use a sphere instead of a cube :)

 //------------------------------//
 //  Tutorial_8.cs              //
 //  Written by Alucard Jay      //
 //  2014/6/29                   //
 //------------------------------//
 
 //  http://libnoise.sourceforge.net/tutorials/tutorial8.html
 
 
 using UnityEngine;
 using System.Collections;
 
 using LibNoise.Unity;
 using LibNoise.Unity.Generator;
 using LibNoise.Unity.Operator;
 
 
 public class Tutorial_8 : MonoBehaviour 
 {
     public int mapSizeX = 512; // for heightmaps, this would be 2^n +1
     public int mapSizeY = 256; // for heightmaps, this would be 2^n +1
     
     public float south = -90.0f;
     public float north = 90.0f;
     
     public float west = -180.0f;
     public float east = 180.0f;
     
     
     public Renderer sphereRenderer; // renderer texture set for testing
     
     private Texture2D texture; // texture created for testing
 
     
     
     //  Persistant Functions
     //    ----------------------------------------------------------------------------
     
     
     void Start() 
     {
         Generate();
     }
     
     
     void Update() 
     {
         if ( Input.GetMouseButtonDown(0) )
             Generate();
     }
     
     
     //  Other Functions
     //    ----------------------------------------------------------------------------
     
     
     void Generate() 
     {
         Perlin mySphere = new Perlin();
         
 
         // ------------------------------------------------------------------------------------------
         
         // - Compiled Terrain -
         
         ModuleBase myModule;
         
         myModule = mySphere;
 
         
         // ------------------------------------------------------------------------------------------
         
         // - Generate -
         
         // this part generates the heightmap to a texture, 
         // and sets the renderer material texture of a sphere to the generated texture
         
         
         Noise2D heightMap;
         
         heightMap = new Noise2D( mapSizeX, mapSizeY, myModule );
         
         heightMap.GenerateSpherical( south, north, west, east );
 
         
         texture = heightMap.GetTexture(GradientPresets.Grayscale);
         
         sphereRenderer.material.mainTexture = texture;
     }
 }


I hope these scripts have been of some help =]


Comment
Add comment · Show 3 · 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 Andros_Spica · Jan 19, 2016 at 05:19 PM 0
Share

Thank you, @alucardj! Very helpful! I've just notice that, after generating the textures, the command "texture.Apply();" is missing. Is this maybe because the scripts were writen for Unity 4 (I'm using Unity 5)? For those following these tutorials, without this line the textures will never be displayed, though never complaining about errors.

avatar image AlucardJay Andros_Spica · Feb 06, 2016 at 12:59 PM 0
Share

Thanks for picking that up. This was done in Unity 4x, though the texture is generated and returned from the LibNoise library (the Noise2D class). Since I normally return an array ins$$anonymous$$d of a texture, havn't noticed this problem. When I have some time, shall look into how the library is creating the texture, it would be strange if texture.Apply(); is not being called there. Thanks again =]

 Noise2D height$$anonymous$$ap = new Noise2D( mapSizeX, mapSizeY, my$$anonymous$$odule );
 // ....
 texture = height$$anonymous$$ap.GetTexture( GradientPresets.Grayscale );
 
avatar image Gemesil · Aug 01, 2020 at 12:07 PM 0
Share

Hello, not to sound ungrateful, this is a great answer but it doesn't seem to work nowadays. I tried messing with it for a bit and I couldn't get the texture to even show up on my mesh. It replaces the material with an instance material but doesn't change the actual texture, or does anything to the terrain.

avatar image
0

Answer by HumanSquid · Feb 13, 2015 at 05:05 AM

You can also get tutorials for this at github:

https://github.com/ricardojmendez/LibNoiseTutorials

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
avatar image
0

Answer by relinwar · Nov 01, 2017 at 03:40 PM

Hey guys, when I try out the script, it says GradientPresets does not exist in current context. Has it been changed?

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 KingHandspider · Oct 11, 2018 at 01:36 PM 0
Share

Remove the .Unity from the LibNoise namespace declarations. I know this is answer is almost a year late, but I solved the problem so I thought I'd mention it :)

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

26 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

Related Questions

how to manually make a voxel terrain? 1 Answer

Voxel terrain with heights based on biomes 0 Answers

How can I implement "3D voxel digging"? 2 Answers

How can i make this noise generated terrain more interesting? 1 Answer

[BEGINNER] Generating Terrain with Perlin noise flat and nothing happens ? 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