Coder Social home page Coder Social logo

fastnoise_csharp's Introduction

discord

Depreciated

This version of FastNoise is now depreciated, please look into using FastNoise Lite which is the successor to this library.

FastNoise

This is the C# version of FastNoise

FastNoise is an open source noise generation library with a large collection of different noise algorithms. This library has been designed for realtime usage from the ground up, so has been optimised for speed without sacrificing noise quality.

This project started when my search to find a good noise library for procedural terrain generation concluded without an obvious choice. I enjoyed the options and customisation of Accidental Noise Library and the speed of LibNoise, so many of the techniques from these libraries and the knowledge I gained from reading through their source has gone into creating FastNoise.

I have now also created FastNoise SIMD, which utilises SIMD CPU instructions to gain huge performance boosts. It is slightly less flexible and cannot be converted to other languages, but if you can I would highly suggest using this for heavy noise generation loads.

Features

  • Value Noise 2D, 3D
  • Perlin Noise 2D, 3D
  • Simplex Noise 2D, 3D, 4D
  • Cubic Noise 2D, 3D
  • Gradient Perturb 2D, 3D
  • Multiple fractal options for all of the above
  • Cellular (Voronoi) Noise 2D, 3D
  • White Noise 2D, 3D, 4D
  • Supports floats or doubles

Wiki

Usage and documentation available in wiki

Wiki Link

Related repositories

Credit to CubicNoise for the cubic noise algorithm

FastNoise Preview

I have written a compact testing application for all the features included in FastNoise with a visual representation. I use this for development purposes and testing noise settings used in terrain generation.

Download links can be found in the Releases Section.

FastNoise Preview

Performance Comparisons

Benchmarking done on C++ version.

Using default noise settings on FastNoise and matching those settings across the other libraries where possible.

Timings below are x1000 ns to generate 32x32x32 points of noise on a single thread.

  • CPU: Intel Xeon Skylake @ 2.0Ghz
  • Compiler: Intel 17.0 x64
Noise Type FastNoise FastNoiseSIMD AVX2 LibNoise FastNoise 2D
White Noise 141 13 111
Value 635 160 364
Perlin 964 342 1409 476
Simplex 1189 340 875
Cellular 2933 1472 56960 1074
Cubic 2933 1393 872

Comparision of fractal performance here.

Examples

Cellular Noise

Cellular Noise

Cellular Noise

Cellular Noise

Fractal Noise

Fractal Noise

Value Noise

Value Noise

White Noise

White Noise

Gradient Perturb

Gradient Perturb

Gradient Perturb

Gradient Perturb

Any suggestions or questions welcome

fastnoise_csharp's People

Contributors

auburn avatar jackmott avatar kdotjpg avatar rover656 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fastnoise_csharp's Issues

Arithmetic overflow

I'm getting the following error:

System.OverflowException: Arithmetic operation resulted in an overflow.

...in this line:

hash = hash * hash * hash * 60493;

I'm a newbie when it comes both to hashing and to C#, but after some poking around online and some experimenting with compilation options...should this code be wrapped in an unchecked {} block so that it doesn't throw an error when checked arithmetic is turned on?

GetCubic(x,y) not use seed

public FN_DECIMAL GetCubic(FN_DECIMAL x, FN_DECIMAL y)
{
	x *= m_frequency;
	y *= m_frequency;

	return SingleCubic(0, x, y);
}

Why "0" is passed instead of m_seed?

FastNoise Preview default values

I was not able to find stricte Windows Forms source of FastNoisePreview.exe. So my issue is that I have no way of knowing which noise type is used as a default for Noise Lookup, when it comes to Cellular. Also, Gradient Perturb in C# has no simple enum, instead it accepts a bunch of floats. I am specifically looking for the True - Fractal option. Would it be possible to open up to the public those variables?

Add some examples and a reference

It would be great if you could add some simple examples how to use this library.

And I know that there is a reference for the C++ version, but maybe you can port it for C#

Possible flaw in Simplex Noise

Hello! I'm looking around for some coherent noise generation solution for landscape generator demo and have spotted a FastNoise C#. After some visualization tests I catch a some flaw in Simpex noise output.

Visualization screenshots:
shaded http://take.ms/9QVGI
wireframe http://take.ms/cG1bN

Noise params:
Just 2D Simplex noise, 1 octave.
Frequency - 0.002
Amplification - 100

Perlin noise doesn't produce visible artifacts for given parameters.

Seed value doesn't change Simplex/Perlin noise output

Hi again!
Next code block outputs equal result for all calls:

var fast = new FastNoise(0);
Debug.Log(fast.GetSimplex(1000, 1000));

fast.SetSeed(1000);
Debug.Log(fast.GetSimplex(1000, 1000));

fast.SetSeed(-5000);
Debug.Log(fast.GetSimplex(1000, 1000));

Same behavior for GetPerlin() method. I have tried create new instance for every call with no luck. Can I miss something?

Seems to be possible to convert into hardware implementation

FastNoise seems to be almost completely possible to convert into an FPGA-based hardware implementation with our Hastlayer project. Hastlayer can automatically convert a subset of .NET into hardware implementations, providing significantly better performance in massively parallelizable compute-bound algorithms with lower power consumption.

The only issue is that it uses floats or doubles, which are not supported by Hastlayer. Nevertheless floating point will be soon with posits, which are more accurate. Also, fixed point computations are supported. Would this be sufficient?

Also, FPGAs are only feasibly if a high degree of parallelization is possible, which I don't yet see where would be possible here.

Furthermore, before anything a test suite and visualization would help a lot but I don't think there is one for this library (there is some visualization tool for FastNoise SIMD though, right?).

Would be quite cool. What do you think?

Suggestion: audio noise

I am impressed with the performance. One thought crossed my mind - it would be very interesting if you reuse some algorithms and simd experience and make DastAudioNoise variation.

Crash when clicking Up/Down

I downloaded FastNoise_Preview_0.4 and clicked "3D" checkbox and then "Down" and it crashed. "Unhandled exception..."

************** Exception Text **************
System.FormatException: Input string was not in a correct format.
at System.Number.ParseSingle(String value, NumberStyles options, NumberFormatInfo numfmt)
at System.Convert.ToSingle(String value)
at Project1.MyForm.upButton_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

upm package for Unity

Hello. Love this library, I was introduced to it by a tech artist coworker of mine! He pulled down the source and put it directly into our unity project and works great like that.

I understand this isn't Unity-specific code, but it would be great if this repo could support Unity's package manager (upm). It would be pretty simple if you follow the steps below. Unfortunately, part of the steps involves adding a branch and you can't do that from within a PR, otherwise I would've opened a PR.

Steps:

  1. Add a long-lived branch called upm
  2. Checkout the upm branch
  3. [Optional] Put namespace Auburns around the FastNoise class
  4. Create a Runtime folder at the root of the repo and move FastNoise.cs into it
  5. Create Runtime/Auburns.FastNoise.asmdef (file contents below)
  6. Add package.json to the root (file contents below)

That's just about it. At that point, people can point to this repo directly for Unity consumption without having to copy/paste this code. More info here: https://docs.unity3d.com/Manual/upm-git.html

Alternatively, I'm more than willing to do this work myself if you add me as a contributor, even if that's a temporary arrangement.

Runtime/Auburns.FastNoise.asmdef:

{
    "name": "Auburns.FastNoise",
    "references": [],
    "includePlatforms": [],
    "excludePlatforms": [],
    "allowUnsafeCode": false,
    "overrideReferences": false,
    "precompiledReferences": [],
    "autoReferenced": false,
    "defineConstraints": [],
    "versionDefines": []
}

package.json

{
  "name": "com.auburns.fastnoise",
  "displayName": "FastNoise",
  "description": "This is the C# version of FastNoise https://github.com/Auburns/FastNoise_CSharp",
  "version": "1.0.0",
  "unity": "2019.1",
  "unityRelease": "4f1",
  "keywords": [
    "FastNoise",
    "fast",
    "noise"
  ]
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.