/JNoise

A Library that allows you to generate noise using different algorithms.

Primary LanguageJavaGNU General Public License v3.0GPL-3.0

JNoise

banner

license GitHub release (latest by date) standard-readme compliant Discord

JNoise is a simple to use java-library for generating noise (including gradient noise) in Java.

JNoise was created in early 2020 by Articdive. It was created for a project in Minecraft for custom terrain generation. It works for all Java 11+ apps and is built using Gradle.

Table of Contents

Install

Maven & Gradle

To add JNoise to your project using Gradle or Maven:

Dependency (Maven):

<dependency>
    <groupId>de.articdive</groupId>
    <artifactId>jnoise</artifactId>
    <version>VERSION</version>
</dependency>

Repository (Gradle Kotlin DSL)

repositories {
    mavenCentral()
}

Dependency (Gradle Kotlin DSL)

dependencies {
    // JNoise Library
    implementation("de.articdive:jnoise:VERSION")
}

Usage

Picking your Noise Algorithm.

The JNoise library supports "Perlin", "OpenSimplex", "Value", "Worley" and "White" noise.

It also supports modules with which you can octavate (fractalize) and combine different noise types.

Every noise-type has different customizable features, e.g. Perlin Noise has different types of interpolation to choose from and Worley Noise's point distribution can be altered.

Normally if you are using an IDE, the code-completition is intuitive enough to use this library without having to check the source-code.

Nevertheless, the Github Wiki contains more than enough information to acquire achieved results.

Example: Creating a noise-generator using Perlin Noise with cosine interpolation.

public JNoise perlinCosine = JNoise.newBuilder().perlin().setInterpolation(InterpolationType.COSINE).setSeed(1729).build();

Getting Noise Values

The Noise's dimension has to do with the amount of parameters. If you add two doubles after the getNoise method, you will receive 2 dimensional noise.

All Noise Implementations support 1D, 2D, 3D and 4D noise.

Example: Getting 2D Perlin-Noise:

public JNoise perlinLinear = JNoise.newBuilder().perlin().setInterpolation(InterpolationType.LINEAR).setSeed(1629).build();
public double getNoise(double x, double y){
    // 1D Noise
    return perlinLinear.getNoise(x, y);
}

Example: Getting 3D Perlin-Noise:

public JNoise perlinLinear = JNoise.newBuilder().perlin().setInterpolation(InterpolationType.LINEAR).setSeed(1629).build();
public double getNoise(double x, double y, double z){
    // 3D Noise
    return perlinLinear.getNoise(x, y, z);
}

Getting Octavated (Fractal) Noise Values

In this case, the way to get octavated noise values is the exact same. However, we must add a NoiseModule ( the OctavationModule) to our JNoise instance.

Example: Creating a noise-generator using octavated Perlin Noise with cosine interpolation.

public JNoise octavatedPerlin = JNoise.newBuilder().perlin().setInterpolation(InterpolationType.COSINE).addModule(OctavationModule.newBuilder().setOctaves(4).setPersistence(1.0).setLacunarity(1.0).build()).build();

Customizable Features

All noise types have a customizable seed.

Perlin & Value Noise

  • Frequency
  • Interpolation function
  • Fade function

Worley Noise

  • Frequency
  • Distance function
  • Feature point amount

OpenSimplex Noise

  • Frequency
  • Fast & SuperSimplex algorithms
  • Simplex variants

White Noise

  • Frequency

Octavation Module

  • The underlying noise type to be octavated
  • Amount of octaves
  • Lacunarity
  • Persistance / Gain
  • Fractal functions (FBM, Billow & Ridged)
  • Seed incrementation per octave (Increases the seed by 1 each octave)

Combination Moudle

  • Addition
  • Min/Max
  • Multiplication
  • Power

Maintainers

@Articdive

Acknowledgements

@Ken Perlin's work on Perlin Noise.

@Kurt Spencer's work on OpenSimplex2 located here.

@Steven Worley's work on Worley Noise.

Contributing

See the contributing file!

License

GNU General Public License v3.0 or later © Articdive