Skip to content

taKana671/NoiseTexture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NoiseTexture

This repository contains python and cython codes that can generate noise images, which can be used for texture and heightmap to visualize the terrain in 3D. In the python modules, numpy, and in the Cython modules, C array is mainly used. Those modules have the same functions, which return the array to be converted to an image. Their difference is speed. See speed comparison result below.

Using the texture_generator's methods, textures such as clouds and cubemaps can be procedurally created. See texture_generator.

Requirements

  • Cython 3.0.12
  • numpy 2.2.4
  • opencv-contrib-python 4.11.0.86
  • opencv-python 4.11.0.86

Environment

  • Python 3.12
  • Windows11

Building Cython code

Clone this repository with submodule.

git clone --recursive https://github.com/taKana671/NoiseTexture.git

Build cython code.

cd NoiseTexture
python setup.py build_ext --inplace

If the error like "ModuleNotFoundError: No module named ‘distutils’" occurs, install the setuptools.

pip install setuptools

Noise Images

Example

from cynoise.perlin import PerlinNoise
# from pynoise.perlin import PerlinNoise
from output_image import output_image_8bit, output_image_16bit

maker = PerlinNoise()
arr = maker.noise3()
output_image_8bit(arr)
output_image_16bit(arr)

# change the number of lattices and the image size. The grid default is 4, size default is 256. 
maker = PerlinNoise(size=512, grid=8)

Noise that can be generated

A noise image is output as png file.
For more details of methods and parameters, please see source codes.

Image Image Image

Speed ​​comparison

The execution time of each methods were measured like below.

maker = VoroniNoise()
result = %timeit -o maker.noise2()
print(result.best, result.loops, result.repeat)
python cython
method best(s) loops repeat best(s) loops repeat
PerlinNoise.noise2 1.258439 1 7 0.016928 10 7
PerlinNoise.noise3 2.113114 1 7 0.023845 10 7
PerlinNoise.fractal2 5.185004 1 7 0.047277 10 7
PerlinNoise.warp2_rot 21.5.049 1 7 0.167894 1 7
PerlinNoise.wrap2 20.60505 1 7 0.162479 10 7
CellularNoise.noise2 1.772891 1 7 0.034365 10 7
CellularNoise.noise3 4.445742 1 7 0.076830 10 7
CellularNoise.noise24 5.562702 1 7 0.089216 10 7
CellularNoise.cnoise2 5.574327 1 7 0.146625 10 7
CellularNoise.cnoise3 15.21613 1 7 0.330184 1 7
PeriodicNoise.noise2 1.511534 1 7 0.017240 100 7
PeriodicNoise.noise3 2.522443 1 7 0.023741 10 7
VoronoiNoise.noise2() 1.782102 1 7 0.113907 10 7
VoronoiNoise.noise3() 4.200216 1 7 0.179295 10 7
VoronoiEdges.edge2() 16.96586 1 7 0.195019 1 7
VoronoiEdges.edge3() 83.08460 1 7 1.026584 1 7
VoronoiRoundEdges.round2() 18.23457 1 7 0.245364 1 7
VoronoiRoundEdges.round3() 84.45329 1 7 1.233588 1 7
SimplexNoise.noise2 1.656967 1 7 0.020974 10 7
SimplexNoise.noise3 4.337698 1 7 0.024148 10 7
SimplexNoise.fractal2 6.711880 1 7 0.065214 10 7
SimplexNoise.fractal3 17.35970 1 7 0.083178 10 7
ValueNoise.noise2 1.128080 1 7 0.016823 100 7
ValueNoise.noise3 1.566021 1 7 0.022034 10 7
ValueNoise.grad2 3.875698 1 7 0.034712 10 7
ValueNoise.fractal2 3.839937 1 7 0.041812 10 7
ValueNoise.warp2_rot 16.90730 1 7 0.151481 10 7
ValueNoise.warp2 15.49489 1 7 0.142454 10 7

Releases

No releases published

Packages

No packages published