https://github.com/jpvt/perlin-cupy
Perlin-NumPy for GPU
https://github.com/jpvt/perlin-cupy
cupy noise perlin-noise perlin-noise-3d perlin-noise-generator
Last synced: 8 months ago
JSON representation
Perlin-NumPy for GPU
- Host: GitHub
- URL: https://github.com/jpvt/perlin-cupy
- Owner: jpvt
- License: mit
- Created: 2021-07-21T19:12:58.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-09-15T18:17:50.000Z (almost 5 years ago)
- Last Synced: 2025-03-12T13:37:42.554Z (over 1 year ago)
- Topics: cupy, noise, perlin-noise, perlin-noise-3d, perlin-noise-generator
- Language: Python
- Homepage: https://pypi.org/project/perlin-cupy/
- Size: 2.57 MB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Perlin-CuPy: Perlin-NumPy for GPU
[](https://pypi.org/project/perlin-cupy/)
[](https://github.com/jpvt/perlin-cupy/blob/main/LICENSE)
[](https://www.jpvteixeira.com/)
[**Install**](https://github.com/jpvt/perlin-cupy#installation)
| [**Examples**](https://github.com/jpvt/perlin-cupy/tree/main/docs/examples)
Perlin-CuPy is a Perlin-NumPy compatible library for GPU-accelerated Perlin Noise generation.
Perlin-CuPy acts as a drop-in replacement to run [existing Perlin-NumPy code](https://github.com/pvigier/perlin-numpy) on NVIDIA CUDA platforms.
```py
from perlin_cupy import (
generate_fractal_noise_2d, generate_fractal_noise_3d,
generate_perlin_noise_2d, generate_perlin_noise_3d
)
```
## Installation
Wheel (precompiled binary package) is available for Linux (x86_64). We've currently tested only for CUDA 11.3 platform using CuPy v11.3, but it should work for any CuPy version installed in your environment.
| Platform | Command |
| ------------- | ------------------------------------ |
| CUDA 11.3 | `pip install perlin-cupy` |
### Requirements
* [NVIDIA CUDA GPU](https://developer.nvidia.com/cuda-gpus) with the Compute Capability 3.0 or larger.
* [CUDA Toolkit](https://developer.nvidia.com/cuda-toolkit): v10.0 / v10.1 / v10.2 / v11.0 / v11.1 / v11.2 / v11.3
### Python Dependencies
* [CuPy](https://pypi.org/project/cupy/): v10.0 / v10.1 / v10.2 / v11.0 / v11.1 / v11.2 / v11.3
## Usage
The usage is exactly the same as [Perlin-NumPy](https://github.com/pvigier/perlin-numpy).
### 2D noise
The function `generate_perlin_noise_2d` generates a 2D texture of perlin noise. Its parameters are:
* `shape`: shape of the generated array (tuple of 2 ints)
* `res`: number of periods of noise to generate along each axis (tuple of 2 ints)
* `tileable`: if the noise should be tileable along each axis (tuple of 2 bools)
Note: `shape` must be a multiple of `res`
The function `generate_fractal_noise_2d` combines several octaves of 2D perlin noise to make 2D fractal noise. Its parameters are:
* `shape`: shape of the generated array (tuple of 2 ints)
* `res`: number of periods of noise to generate along each axis (tuple of 2 ints)
* `octaves`: number of octaves in the noise (int)
* `persistence`: scaling factor between two octaves (float)
* `lacunarity`: frequency factor between two octaves (float)
* `tileable`: if the noise should be tileable along each axis (tuple of 2 bools)
Note: `shape` must be a multiple of `lacunarity^(octaves-1)*res`
### 3D noise
The function `generate_perlin_noise_3d` generates a 3D texture of perlin noise. Its parameters are:
* `shape`: shape of the generated array (tuple of 3 ints)
* `res`: number of periods of noise to generate along each axis (tuple of 3 ints)
* `tileable`: if the noise should be tileable along each axis (tuple of 3 bools)
Note: `shape` must be a multiple of `res`
The function `generate_fractal_noise_2d` combines several octaves of 3D perlin noise to make 3D fractal noise. Its parameters are:
* `shape`: shape of the generated array (tuple of 3 ints)
* `res`: number of periods of noise to generate along each axis (tuple of 3 ints)
* `octaves`: number of octaves in the noise (int)
* `persistence`: scaling factor between two octaves (float)
* `lacunarity`: frequency factor between two octaves (float)
* `tileable`: if the noise should be tileable along each axis (tuple of 3 bools)
Note: `shape` must be a multiple of `lacunarity^(octaves-1)*res`
## License
MIT License (See [LICENSE](https://github.com/jpvt/perlin-cupy/blob/main/LICENSE) file).
Perlin-CuPy is designed based on Perlin-NumPy's API (see [LICENSE_THIRD_PARTY](https://github.com/jpvt/perlin-cupy/blob/main/docs/LICENSE_THIRD_PARTY) file) by Pierre Vigier.
Perlin-CuPy is being maintained and developed by [João Pedro Vasconcelos](https://github.com/jpvt) and [Bruno Barufaldi](https://github.com/bbarufaldi).
Icon logo made by [Eucalyp](https://creativemarket.com/eucalyp) from [Flaticon](https://www.flaticon.com/).