LibNoise Ported to Unity

Ported LibNoise noise library from LibNoise.Xna to Unity. Like those two, it is released under the LGPL so it can be used and modified pretty much however you like.

Generates Perlin, RiggedMultifractal,Voronoi and Billow noises and has Operators for combining them. Noise2D is a convenience class for creating Texture2D from noises.

Now also available from github, thanks to Arges:

Simple Demo scene included in attached Unitypackage.

439185–15264–$LibNoiseUnity.unitypackage (57.6 KB)

4 Likes

Nice work!

Thanks! Wanted to do this myself but you made it first.

I’ve found so many great free resources for unity. This project was an easy karma builder and I learned a bunch in the process. Let me know if any issues crop up.

Great job, not much need for it right now (can get away with my own poor perlin) but I’m sure I’ll use it in the future.

When trying the demo I get :

Assets/Demo.cs(85,18): error CS0117: System.IO.File' does not contain a definition for WriteAllBytes’

Hmm, What Unity version?

for the moment you can just disable to write to PNG code in there.

3.1.0.f4 Windows 7 64 bit

Did you get it to work by disabling the write to PNG?

I am wondering if there is a simple method to generate a sphere as a module? Something like
http://graphics-illustrations.com/wp-content/uploads/2008/03/013.jpg

Spheres spheres = new Spheres(0.25); kind of works, but the corners begin to climb again.

Hmm, not sure. Maybe write a Clamp module?

var island_p =  Spheres(0.20);
    var const_sub_p = Const(-0.4); //Distance to edge.  Smaller number makes it closer to the edge
    var const_mult_p = Const(5.0); //falloff
    var moduleBase = new Add(island_p, const_sub_p);
    var islandmult_p  = new Multiply(moduleBase, const_mult_p);
    var m_noiseMap = new Noise2D(512, 512, islandmult_p);

If I run into the answer I’ll edit this post. But can I recycle the variables? moduleBase = new Multiply(yada,yada); throws an error

BCE0022: Cannot convert 'LibNoise.Unity.Operator.Multiply' to 'LibNoise.Unity.Operator.Add'.

edit: post below solves it. thanks!

If you explicitly type moduleBase as ModuleBase it should work. I don’t know uscript, but something like:

var moduleBase : ModuleBase = new Add(island_p, const_sub_p);
//do stuff here
moduleBase = new Multiply(island_p, const_sub_p);
1 Like

Hi everyone,

I’ve imported pakfront’s port to git, and created a github repository:

https://github.com/ricardojmendez/LibNoise.Unity/

Bear in mind that this is the library alone, without the example. You can find a few bugfixes on this branch, but consider it a work in progress.

Cheers,

Could you tell me what is the main difference between your xna port and this http://libnoisedotnet.codeplex.com/ one?

The one from the link works as is without any effort. Still id like to know if theres anything different in yours.

Working with this again, I’m trying to use Scale but I can’t find out how to use it.

var terrainbase : ModuleBase = Select(type_min, type_max, type_falloff, p_mountain_p, p_flatlandmod_p);

It requires 2 input and 1 controller - how do I add the other input to it?

Same here… I’m looking through the source code to figure this out…

It seems to be an oversight I believe… if you look through the Select class, you’ll see that the constructor maps the input module to m_modules[0], and the ‘controller’ to m_modules[1]… now, the Controller property maps the given value to m_modules[2], so I believe we are supposed to pass both input modules to the constructor, and set the control module through it’s property… Even though the contructor says the second module is the controller…

I haven’t tried it yet, but let’s see how it goes… I’ll post back with any news :slight_smile:

BTW, great work on this port!! my terrain is looking infinitely better now :slight_smile:

Cheers

EDIT: Got it to work!! the constructor indeed has those parameters mislabeled, and there is one other thing:

the Select constructor is calling it’s base class with only 2 module “slots”, so I just tweaked the constructor to pass 3 to the base call… (you gotta do this, or else you get an index out of range exception) :slight_smile:

Anyways, it works!! thanks a million for the port!!

Cheers again!

Probably very little, except I added some convenience methods for handling Unity data types like Texture2D.

Can you post the exact code fixes so we can wrap them into the git repo? OR even do it yourself if you are comfortable with it.

Im having a problem with the Perlin class. I create a new Perlin() and call GetValue(x,y,z) but the value is always 0. Is there something im missing?

Thank you very much for this port. It’s been a great help. Cheers.