Skip to main content

A simple and fast Perlin noise generation library

Project description

Fast Perlin Noise

This is a very fast Perlin noise library, mostly in Go with Python bindings, that I developed upon trying out a few other available Python libraries and realized that none were fast enough for my project requirements. Algorithms are from the libnoise dotnet project which I ported to Go.

Installation

To install fast_perlin_noise,

pip3 install fast-perlin-noise

Wheels are automatically built for Windows, Linux, and macOS for x86-64 and ARM64 architectures. If a wheel does not exist for your platform, you will require a Go compiler to complete the installation.

Dependencies

fast_perlin_noise has very limited dependencies: only numpy is required!

Tests and Examples

fast_perlin_noise has a very beginner friendly Python interface, with optional advanced use.

from fast_perlin_noise import PerlinNoise
import numpy as np
import matplotlib.pyplot as plt

noise_generator: PerlinNoise = PerlinNoise(width=256, height=256)
noise_image: np.ndarray = noise_generator.generate_noise_matrix()

plt.imshow(noise_image)  # View the resulting noise

Perlin Noise

You can run and look at example/example.py to see this in action.

Output

fast_perlin_noise currently outputs a matrix (an ndarray with the shape m, n) of noise of which the values range from 0.0 to 1.0.

Interface and Parameters

For more advanced use, many parameters can be tuned to adjust the resulting noise. Perlin noise can be generated using the generate_noise_matrix function.

Parameter Type Description
width uint Width of resultant matrix.
height uint Height of resultant matrix.
persistence float Intensity falloff coefficient of subsequent noise layers.
numLayers uint Number of simplex noise layers to use.
roughness float Frequency increase coefficient for subsequent noise layers.
baseRoughness float Initial frequency for noise
strength float Scalar multiplier for noise values
randomSeed float Define the random seed to be used

Controlling Noise Output

Behaviour of the noise can be changed by changing parameters to the PerlinNoise interface. Settings include width and height to determine the dimensions of the resulting matrix. baseRoughness and roughness to control the frequency and frequency falloff. persistence to change the impact of subsequent layers (low value results in a "softer" look). numLayers controls how many layers of noise will be used (more layers results in more complex, structured noise). strength is a simple scalar multiplier to the matrix (control intensity of noise). Lastly, randomSeed can be changed to change the seed of the noise (fast_perlin_noise is deterministic when randomSeed is known).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fast_perlin_noise-1.1.1.tar.gz (96.3 kB view details)

Uploaded Source

File details

Details for the file fast_perlin_noise-1.1.1.tar.gz.

File metadata

  • Download URL: fast_perlin_noise-1.1.1.tar.gz
  • Upload date:
  • Size: 96.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for fast_perlin_noise-1.1.1.tar.gz
Algorithm Hash digest
SHA256 6e0dafb287b369ede401751d3be5ec7c2d5cef96f0ac37f07a0a426aef3b73d4
MD5 2b75d62ab1481e3bc1b3d22569f29e1e
BLAKE2b-256 84d079d0288148a68044a3398106f1e5a0f7893ad86ae628e11ecc1df4acf362

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page