[0.3 released] Noise++: A coherent noise-generating library

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
User avatar
kickin_bear
Kobold
Posts: 31
Joined: Sun Apr 06, 2008 10:06 pm
Location: Karlsruhe, Germany

[0.3 released] Noise++: A coherent noise-generating library

Post by kickin_bear »

Noise++ is a coherent noise-generating library I created for my current project. It's released under BSD license.

http://noisepp.sourceforge.net/

Features:
:arrow: coherent noise modules (perlin noise, ridged-multifractal, ...)
:arrow: value transformation modules (addition, multipy, ...)
:arrow: selection module
:arrow: coordinate transformation modules (scale, transform, turbulence, ...)
:arrow: 1D, 2D and 3D versions of all modules
:arrow: supports single and double precision
:arrow: very well optimized (much faster than libnoise - check comparision example)
:arrow: supports multi-threading
:arrow: all 3D and most 2D noise generation modules produce the same output than the corresponding libnoise modules

I hope this will be useful for some of you.

Download:
Source Package: noisepp-0.3.zip
Performance comparision example binary for Windows: noisepp-0.3-test-bin.zip
Editor binary for Windows: noisepp-0.3-editor-bin.zip

Regards,
kickin_bear
Last edited by kickin_bear on Tue Jun 24, 2008 7:37 pm, edited 4 times in total.
User avatar
HexiDave
OGRE Expert User
OGRE Expert User
Posts: 1538
Joined: Sat Jan 14, 2006 8:00 pm
x 1

Post by HexiDave »

Just tested it out - the speed is definitely there. Hopefully the quality is as good. And, yes, the one thing that irked me about libnoise was that it didn't have 2D noise functions as well.

If the quality is good, I'll probably make the switch - nicely done :D

A few suggestions from the example:

1. I don't know how it works for Linux machines, but on Windows as soon as it's done running the test, the window closes - there's nothing at the end to hold it on-screen. Try putting a "All done!" message followed by "cin.get();" to keep it in place so we can see the message.

2. Might be worth it to use #if's for the multi-thread example code, otherwise you have to comment it all out for it to compile.

3. There was something else - I'll edit if I can remember.
User avatar
kickin_bear
Kobold
Posts: 31
Joined: Sun Apr 06, 2008 10:06 pm
Location: Karlsruhe, Germany

Post by kickin_bear »

thanks for your suggestions :)
I added them to the new release.
Also added an example binary (compiled in double precision).

About noise quality: The noise quality should be the same as in libnoise. Don't checked this for all cases, but I'm very sure for the perlin noise module. The example generates 1,000,000 values with libnoise and Noise++ and the mean difference is 1e-11 with double precision enabled.
User avatar
HexiDave
OGRE Expert User
OGRE Expert User
Posts: 1538
Joined: Sat Jan 14, 2006 8:00 pm
x 1

Post by HexiDave »

Ya, they're probably quite similar then. As long as the basics are right (which they seem to be), then everything else should fall in line.

What was the biggest improvement you made with speed? Was it just that you cut down on the amount of virtual functions or something else?
User avatar
Praetor
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3335
Joined: Tue Jun 21, 2005 8:26 pm
Location: Rochester, New York, US
x 3
Contact:

Post by Praetor »

This is very neat. Performance enhancement over libnoise is enough to make me happy. I'll have to check this out. Given what you have done now, what do you want to do with it in the future? Is there a roadmap of things you're going to add or change with it?
User avatar
kickin_bear
Kobold
Posts: 31
Joined: Sun Apr 06, 2008 10:06 pm
Location: Karlsruhe, Germany

Post by kickin_bear »

I don't know what exactly makes it faster than libnoise. I have just read some articles about the noise functions and tried to implement them. I don't excepted it to be that fast but I think it's mainly because nearly any function is declared as inline and I tried to help the compiler optimizing the code by marking variables as const and so on. Another thing is that I use a Pipeline. For example for the noise module you have to calculate scale factors for each octave, which can be done once after the parameters are set. I do this when adding an Module to the Pipeline. Libnoise has no way to realize when the module parameters are completely set and so it calculates this scale factors each time you call GetValue()
User avatar
kickin_bear
Kobold
Posts: 31
Joined: Sun Apr 06, 2008 10:06 pm
Location: Karlsruhe, Germany

Post by kickin_bear »

Yes there is a roadmap. At first I'll add some modules that create color and normal maps from the noise output. The colors will be generated not only by heights but also by slope. After that I plan to make an editor for Noise++'s noise-generation-pipelines where you can manage modules, their parameters, see a live view of the output and finally export them to easily load an entire noise-generation-pipeline into your game.
User avatar
Praetor
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3335
Joined: Tue Jun 21, 2005 8:26 pm
Location: Rochester, New York, US
x 3
Contact:

Post by Praetor »

Sounds like a nice plan.

Might be interesting to investigate exactly why your modules are faster than libnoise, but your casual observations sound pretty plausible.
Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
x 1
Contact:

Post by Vectrex »

very nice. I'll check this out soon as I use libnoise for loads of stuff.
User avatar
steven
Gnoll
Posts: 657
Joined: Mon Feb 28, 2005 1:53 pm
Location: Australia - Canberra (ex - Switzerland - Geneva)
Contact:

Post by steven »

Seems very nice. I will definitely keep an eye on it.

For several reasons we didn't use the boost::Thread anymore in our engine.

Do you think you could make the multithread support generic enough that we can supply our own thread?

[EDIT]

I see that all the thread code is in NoiseThreadedPipeline.h.
This is nice it shouldn't be too complicated to modify this file to add our own thread.
Really nice job.
[/EDIT]
User avatar
kickin_bear
Kobold
Posts: 31
Joined: Sun Apr 06, 2008 10:06 pm
Location: Karlsruhe, Germany

Post by kickin_bear »

Yes currently all thread code is in NoiseThreadedPipeline.h, but there will be some elsewhere in the future. I already wrote my own thread library (it is integrated in Noise++ in the svn trunk) using pthreads in Linux or Windows threads. Will make a release after some testing ...
If you want to use your own implementation you can just modify the threadpp::... classes then.

Edit:
version 0.0.3 released
User avatar
kickin_bear
Kobold
Posts: 31
Joined: Sun Apr 06, 2008 10:06 pm
Location: Karlsruhe, Germany

Editor progress

Post by kickin_bear »

Image

I've just released a first editor binary snapshot (source is avaible through SVN)
Currently there are only a few modules supported but the interface is nearly done.
On my TODO list:
:arrow: Add all module types supported by Noise++
:arrow: Add export function for binary files which can be easily imported with the Noise++ library
:arrow: Add material support to colorize the output (maybe with exporter, too)
Any suggestions and comments are welcome :)
User avatar
triton
Greenskin
Posts: 138
Joined: Thu Mar 13, 2008 10:25 pm
Location: Portugal

Post by triton »

I think this is gonna be really useful! Thanks. :)
User avatar
SpannerMan
Gold Sponsor
Gold Sponsor
Posts: 446
Joined: Fri May 02, 2003 10:05 am
Location: UK
Contact:

Post by SpannerMan »

Wow, this looks really good!

I would look forward to a binary release and as many composite examples included as possible.

Best of luck :)
User avatar
NoodlesOnMyBack
Goblin
Posts: 200
Joined: Tue Feb 05, 2008 4:14 am
Location: Buenos Aires, Argentina
Contact:

Post by NoodlesOnMyBack »

Thank you so much for this kickin_bear, just in time for me to add this to my project.
MartinBean
Gnome
Posts: 331
Joined: Thu Oct 25, 2007 12:21 pm
Location: The Netherlands

Post by MartinBean »

Holy Crap!!

I've been working with libnoise, but stopped because it is so slow.

Lets see how this one is doing :)
I have not failed... I've just found many ways that wont work
User avatar
kickin_bear
Kobold
Posts: 31
Joined: Sun Apr 06, 2008 10:06 pm
Location: Karlsruhe, Germany

Post by kickin_bear »

MartinBean wrote:Holy Crap!!

I've been working with libnoise, but stopped because it is so slow.

Lets see how this one is doing :)
I hope it meets your expectations :D
Last night I had a look at CUDA and after the editor is done (and I have a new graphics card) a CUDA port of Noise++ is the next thing on my TODO list
MartinBean
Gnome
Posts: 331
Joined: Thu Oct 25, 2007 12:21 pm
Location: The Netherlands

Post by MartinBean »

A long time a go I looked at CUDA too, to do the heavy calcs on the GPU.

I stopped because I needed to spend my time somewhere else :(

But I really think it is the way to go!!

Realtime endless terrain generation with noise, that would minimize the download size considerably!
I have not failed... I've just found many ways that wont work
User avatar
Grom
Hobgoblin
Posts: 523
Joined: Fri Jan 06, 2006 6:35 pm

Post by Grom »

wow. I was using libnoise for both my terrain and clouds. I swapped your implementation in and it worked painlessly! I'm truly impressed.
User avatar
kickin_bear
Kobold
Posts: 31
Joined: Sun Apr 06, 2008 10:06 pm
Location: Karlsruhe, Germany

new release, finally.

Post by kickin_bear »

I used my 4-day-weekend (our A-levels wrote their "Abitur" exams) to create another release. Big changelog since last release:
:arrow: fixed perlin module getter function name
:arrow: added editor
:arrow: added select and turbulence module
:arrow: added scale parameter to perlin, billow and ridged-multi module
:arrow: removed module dimension specialization. there is now only one module class for each module type
:arrow: added module IDs
:arrow: added validators to curve and terrace editor modules
:arrow: made Pipeline::addJob thread safe
:arrow: added streams, reader and writer to noise utils and an export function to the editor
:arrow: added some noise utils (image, system, renderer)
:arrow: added tree loop validator
:arrow: added new example and Code::Blocks project files
:arrow: improved comparision example
:arrow: added exceptions
:arrow: added plane builder
:arrow: added missing header to Thread++ include file
:arrow: added premake files
:arrow: added editor BMP export function and BuilderCallback class
:arrow: improved documentation, added job queue, improved editor BMP export
:arrow: added getElementID and getElementPtr function to pipeline
:arrow: switched to 2-clause BSD license
I opened a wiki with and build instructions and tutorials.
The editor is not yet done and bugfree, but it is in a state you can use it.
If you have problems, suggestions or other comments just post them here.
And if there is someone who wants to write some more documentation on the wiki (modules, editor, etc.) just contact me and I give you write permissions.
I bought a Geforce 9600GT last week so I will start writing a CUDA-port when I have time to (school again tomorow ... :evil: ... I hate it)

Download:
Source Package: noisepp-0.1.zip
Performance comparision example binary for Windows: noisepp-0.1-test-bin.zip
Editor binary for Windows: noisepp-0.1-editor-bin.zip
User avatar
Brocan
Orc
Posts: 441
Joined: Tue Aug 01, 2006 1:43 am
Location: Spain!!
x 8

Post by Brocan »

I'm going to use this to build my planets. Thank you for the lib :D.

Edit: Uhm, in the editor the checkboard texture haven't parameters and when i try to generate it, nothing happens :?

One advice, when you choose a new module, a separation between purely source modules and blending modules would be great :D
User avatar
kickin_bear
Kobold
Posts: 31
Joined: Sun Apr 06, 2008 10:06 pm
Location: Karlsruhe, Germany

Post by kickin_bear »

the checkerboard uses bit operators internally to generate. So it will change color each unit, which is the default viewing size ( from (0|0) to (1|1) ).
you have to modify it using a scale point module.
One advice, when you choose a new module, a separation between purely source modules and blending modules would be great
Thanks for advice, I'll do that.
User avatar
HexiDave
OGRE Expert User
OGRE Expert User
Posts: 1538
Joined: Sat Jan 14, 2006 8:00 pm
x 1

Post by HexiDave »

Hmm, well, I feel a bit silly as I just ported Libnoise over to use "fast" perlin noise (wanted all the old bits of my work to function as it was) and started building my own editor. I'll keep trucking on mine as I like the feature list it has too :D (plus, I get to finally learn all about the horrors of Managed C++)

Have you had a chance yet to work the non-SSE speed-boosts that Ysaneya wrote about (http://www.gamedev.net/community/forums ... cyear=2007 bottom of the page)? Only took a few minutes to re-work Libnoise's generation code to abuse that and I went from taking 4.5 seconds to generate 1024x1024 samples at 12 octaves (in 3D, of course) to 0.9 seconds. That's one hell of an improvement for such a small amount of work.
beaugard
OGRE Contributor
OGRE Contributor
Posts: 265
Joined: Sun Mar 25, 2007 1:48 pm
x 2

Post by beaugard »

About the first "trick" - he uses a ternary function (which might be faster than floorf, actually) encapsulated in a define, so it might be easy to change.

Code: Select all

	#define NOISE_GENERATOR_INTEGER_CLAMP_X \
		const int x0 = (x > Real(0.0) ? (int)x : (int)x - 1); \
		const int x1 = x0 + 1;
It seems he doesn't use the second trick either, but I cannot imagine it would be hard to add (just a change to interpGradientCoherentNoise function, I think).

kickin_bear, I would be very interested in how these optimizations work. If you have the time maybe you could add them to your perfomance comparison?
User avatar
HexiDave
OGRE Expert User
OGRE Expert User
Posts: 1538
Joined: Sat Jan 14, 2006 8:00 pm
x 1

Post by HexiDave »

The thing is, it's not the "floorf" function that's killing it, it's the conversion from float to int. That assembly code with the (x - 0.5f) - which does the flooring - got me a about a second of time shaved off from my initial test with "vanilla" Libnoise. The second thing was really what did the trick, so be sure to give that a look more than anything.

noise++ is pretty much Libnoise with some new toys thrown in, so the results should be pretty much the same (remember, I was testing 3D noise, so 2D noise should be quite a bit faster).
Post Reply