Giter Club home page Giter Club logo

perlinnoisejava's Introduction

PerlinNoiseJava

SonarCloud Analysis

Java implementation of Perlin Noise algorithm as described in this resource.

About this project

This project is an implementation of the popular Perlin noise algorithm described by Ken Perlin.

This projects also features generators to populate grids of noise in 1 and 2 dimensions that can be updated over time. These generators offer the option of spatial circularity over the grid's borders. For example, connecting both ends of a line generated this way will preserve noise continuity over the new-made junction. For a 2D grid, tiling the grid with itself would also preserve noise continuity over the tile's junction.

Usage

Raw Perlin

The perlin noise core algorithm is accessible through the PerlinNoise class. After creating an instance of the class with a random seed, it can be used as follows:

PerlinNoise perlinNoise = new PerlinNoise(seed);
double noiseValue = perlinNoise.getFor(coordinates);

where coordinates represents a single dimension array of doubles, of length up to 5.

PerlinNoise Generators

The noise generators aim to automatize the generation of noise following a single or double dimensional array. The generators are accessible through their respective builders like such:

LayeredSliceGeneratorBuilder builder = new LayeredSliceGeneratorBuilder(width, height);
LayeredSliceGenerator generator = builder.build();
double[][] noiseValues = generator.getNext();

The number of layers is set using the builder:

builder.withNumberOfLayers(n);

Step sizes in spatial and time dimensions are set with the builder's methods:

builder.setTimeStepSizes(timeStepSizes);
builder.setWidthStepSizes(widthStepSizes);
builder.setHeightStepSizes(heightStepSizes);

where stepSizes is an Iterable<Double> having at least n (number of layers) values.

The amplitude of each layer is set with the builder's method:

builder.withAmplitudes(amplitudes);

which is also an Iterable<Double>, following the same principle as the setXStepSizes() methods.

Spatial circularity option is set with the builder:

builder.withCircularBounds(true);

Parallelization

Parallelization of the noise generation is possible using two paradigms:

  • the ForkJoinPool Java framework, to split line or slice generation into smaller fragments;
  • the ExecutorService framework, to launch generation of each layer simultaneously.

These optimizations are accessible using the builder's methods:

builder.withForkJoinPool(pool);
builder.withLayerExecutorService(executorService);

perlinnoisejava's People

Contributors

lefmaroli avatar dependabot[bot] avatar

Stargazers

 avatar

Watchers

 avatar

perlinnoisejava's Issues

Reuse circular results when available

The spatial circular option is not reusing the smallest tile to fill the remaining space on the tile. This would optimize the process by not recalculating a lot of repeating values.

Make spatial circularity snapping to size optional

Currently spatial step sizes are adjusted automatically to fit spatial dimensions so that an integer number of repeating cycle is possible. This should be optional as it restrict the user from getting a specific step size for a specific grid with circularity.

Circularity in time option

Time circularity should also be offered as an option so that values are repeated after a specific number of invocations of the getNext() method.

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.