caseman / noise Goto Github PK
View Code? Open in Web Editor NEWPerlin noise library for Python
License: MIT License
Perlin noise library for Python
License: MIT License
I noticed that perlin 3d has the ability to repeat, and simplex 2d as well; would it be possible to add simplex 3d repeating?
Heyo, I'm a bit of a python noob, so forgive me if I'm doing something wrong here. When I run python from the repo directory, I can import noise without a problem. When I go up a level, I get this:
import noise
Traceback (most recent call last):
File "", line 1, in
File "noise/init.py", line 12, in
from . import _perlin, _simplex
ImportError: cannot import name _perlin
It can find the noise script just fine, but the noise script can't find perlin and simplex files? Not sure what the fix is for this - it's probably pretty simple but I couldn't find anything on it.
Thanks!
Python 3.4.3 (default, Nov 17 2016, 01:08:31)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
import noise
Traceback (most recent call last):
File "", line 1, in
File "/mnt/c/Users/kalex/Sanity/mmttrpg/python/noise/init.py", line 12, in
from . import _perlin, _simplex
The README links to supplemental information on simplex noise: http://zach.in.tu-clausthal.de/teaching/cg2_08/literatur/simplexnoise.pdf
This link is broken: accessing the URL 404s.
I dug around on the University of Bremen website (Schließlich sind Deutschkurse nützlich) and found what I think is the same document, but at a working URL: http://cgvr.cs.uni-bremen.de/teaching/cg_literatur/simplexnoise.pdf
However, even better than that, I think, is the annotated / corrected version from Stefan Gustavson himself, here http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
Reading the code I found a commentary in simplex constructor, for new a pattern generation. However, every time I call the function with same parameters, the pattern is unchanged. How can I rerandomize the noise pattern?
So far, I tried to shift the window with a random value. Is it correct?
mnoise = [[snoise2(4.0*float(m+random)/float(nt),5.0*float(n+random)/float(nt),16) for m in range(nt)] for n in range(nt)]
Hi there this module is great and I was thinking if it would be useful to add the inverse perlin function
would it be possible to see the noise? I'm using this for terrain generation and the ability to seed the pattern and end up with different variations would be nice (i.e. planet X doesn't have the same landmasses as planet Y). Currently I'm just offsetting the X and Y, but that feels.... kludgy.
i tried to install noise using pip but i got this error
C:\Users\Zhenzhu\Downloads>python -m pip install noise
Collecting noise
Using cached noise-1.2.2.tar.gz (125 kB)
Building wheels for collected packages: noise
Building wheel for noise (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: 'C:\Users\Zhenzhu\AppData\Local\Programs\Python\Python37-32\python.exe' -u -c 'import sy
s, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Zhenzhu\\AppData\\Local\\Temp\\pip-install-yy
np_3j2\\noise\\setup.py'"'"'; __file__='"'"'C:\\Users\\Zhenzhu\\AppData\\Local\\Temp\\pip-install-yy
np_3j2\\noise\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().repla
ce('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_whee
l -d 'C:\Users\Zhenzhu\AppData\Local\Temp\pip-wheel-8w7hu8rj'
cwd: C:\Users\Zhenzhu\AppData\Local\Temp\pip-install-yynp_3j2\noise\
Complete output (14 lines):
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win32-3.7
creating build\lib.win32-3.7\noise
copying perlin.py -> build\lib.win32-3.7\noise
copying shader.py -> build\lib.win32-3.7\noise
copying shader_noise.py -> build\lib.win32-3.7\noise
copying test.py -> build\lib.win32-3.7\noise
copying __init__.py -> build\lib.win32-3.7\noise
running build_ext
building 'noise._simplex' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https:/
/visualstudio.microsoft.com/downloads/
----------------------------------------
ERROR: Failed building wheel for noise
Running setup.py clean for noise
Failed to build noise
Installing collected packages: noise
Running setup.py install for noise ... error
ERROR: Command errored out with exit status 1:
command: 'C:\Users\Zhenzhu\AppData\Local\Programs\Python\Python37-32\python.exe' -u -c 'import
sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Zhenzhu\\AppData\\Local\\Temp\\pip-install-
yynp_3j2\\noise\\setup.py'"'"'; __file__='"'"'C:\\Users\\Zhenzhu\\AppData\\Local\\Temp\\pip-install-
yynp_3j2\\noise\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().rep
lace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install
--record 'C:\Users\Zhenzhu\AppData\Local\Temp\pip-record-8rk8l89l\install-record.txt' --single-versi
on-externally-managed --compile --install-headers 'C:\Users\Zhenzhu\AppData\Local\Programs\Python\Py
thon37-32\Include\noise'
cwd: C:\Users\Zhenzhu\AppData\Local\Temp\pip-install-yynp_3j2\noise\
Complete output (14 lines):
running install
running build
running build_py
creating build
creating build\lib.win32-3.7
creating build\lib.win32-3.7\noise
copying perlin.py -> build\lib.win32-3.7\noise
copying shader.py -> build\lib.win32-3.7\noise
copying shader_noise.py -> build\lib.win32-3.7\noise
copying test.py -> build\lib.win32-3.7\noise
copying __init__.py -> build\lib.win32-3.7\noise
running build_ext
building 'noise._simplex' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https
://visualstudio.microsoft.com/downloads/
----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\Zhenzhu\AppData\Local\Programs\Python\Pytho
n37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Zhenzhu\\A
ppData\\Local\\Temp\\pip-install-yynp_3j2\\noise\\setup.py'"'"'; __file__='"'"'C:\\Users\\Zhenzhu\\A
ppData\\Local\\Temp\\pip-install-yynp_3j2\\noise\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"',
open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __f
ile__, '"'"'exec'"'"'))' install --record 'C:\Users\Zhenzhu\AppData\Local\Temp\pip-record-8rk8l89l\i
nstall-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\Zhenzhu
\AppData\Local\Programs\Python\Python37-32\Include\noise' Check the logs for full command output.
i'm using python 3.7
I was porting the code in pure python from the c++ for vnoise (numpy-accelerated vectorized pure python port https://github.com/plottertools/vnoise (it's about as fast as the pure c++ if you vectorized those calls)), and this base
thing stuck out as a thing that does anything. It's hooked up to nothing.
It shows up 3 times. Once in declaration and twice in the documentation. 0 times in actual code.
Hello,
I'm trying to use the noise library from inside docker alpine.
Installing noise with pip is okay, but when I try to import it I get this error message :
Traceback (most recent call last):
File "map_generator.py", line 1, in <module>
import noise
File "/usr/lib/python3.7/site-packages/noise/__init__.py", line 12, in <module>
from . import _perlin, _simplex
ImportError: Error relocating /usr/lib/python3.7/site-packages/noise/_perlin.cpython-37m-x86_64-linux-gnu.so: grad2: symbol not found
Any idea on how to fix this ?
Hi, thanks for sharing this code. I have used it in my research and would like to acknowledge it in my paper. I have just said "we used noise
" and added a link to the repo. Let me know if you'd like something different, like a link to a Zenodo DOI.
I know the last commit was 2 years ago, but I thought I'd ask.
When using pip to install noise : sudo pip install noise , an error occured :
......
blablabla
......
running build_ext
building 'noise._simplex' extension
creating build/temp.linux-x86_64-2.7
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c _simplex.c -o build/temp.linux-x86_64-2.7/_simplex.o -funroll-loops
_simplex.c:5:20: fatal error: Python.h: Aucun fichier ou dossier de ce type
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
When trying the installation via the github repository, the folder Python.h is also missing:
sudo python setup.py install
......
.....
building 'noise._simplex' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c _simplex.c -o build/temp.linux-x86_64-2.7/_simplex.o -funroll-loops
_simplex.c:5:20: fatal error: Python.h: Aucun fichier ou dossier de ce type
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Anyway, thank for your helpfull librairy.
Gnu-Bricoleur
EDIT : It work with pip3 install but not with pip for the default version of python wich is 2.7 on my distrib, i suppose it work with sudo python3 setup.py install although i didn't try
Today I try terrain generation with different seeds. so I write:
from noise.perlin import SimplexNoise
noise2 = SimplexNoise(hash('a')).noise2
print(noise2(0, 0))
But some error raise:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.8/site-packages/noise/perlin.py", line 171, in noise2
gi0 = perm[ii + perm[jj]] % 12
IndexError: tuple index out of range
I use noise 1.2.2, python 3.8.5, Termux in Android 7.1.1, Linux version 3.18.31
Python 3.6 segfaults when I call snoise4 with any lacunarity argument.
Test program:
#!/usr/bin/python3.6
import noise
noise.snoise4(0, 0, 0, 0, lacunarity=2.0)
Core backtrace:
$ sudo cat ccpp-2019-02-19-06:49:03-23546/core_backtrace
{ "signal": 11
, "executable": "/usr/bin/python3.6"
, "stacktrace":
[ { "crash_thread": true
, "frames":
[ { "address": 140687606631050
, "build_id": "9ce628fe0dcd751ed564f0c78cb272f2f53fc4e1"
, "build_id_offset": 1469066
, "function_name": "vgetargskeywords"
, "file_name": "/usr/lib64/libpython3.6m.so.1.0"
}
, { "address": 140687606648654
, "build_id": "9ce628fe0dcd751ed564f0c78cb272f2f53fc4e1"
, "build_id_offset": 1486670
, "function_name": "PyArg_ParseTupleAndKeywords"
, "file_name": "/usr/lib64/libpython3.6m.so.1.0"
}
, { "address": 140687455583620
, "build_id": "652fb4d937c9140ab592c1e38711860b28954d3c"
, "build_id_offset": 11652
, "function_name": "py_noise4"
, "file_name": "/usr/local/lib64/python3.6/site-packages/noise/_simplex.cpython-36m-x86_64-linux-gnu.so"
}
, { "address": 140687606112159
, "build_id": "9ce628fe0dcd751ed564f0c78cb272f2f53fc4e1"
, "build_id_offset": 950175
, "function_name": "_PyCFunction_FastCallDict"
, "file_name": "/usr/lib64/libpython3.6m.so.1.0"
}
, { "address": 140687606113145
, "build_id": "9ce628fe0dcd751ed564f0c78cb272f2f53fc4e1"
, "build_id_offset": 951161
, "function_name": "_PyCFunction_FastCallKeywords"
, "file_name": "/usr/lib64/libpython3.6m.so.1.0"
}
, { "address": 140687606554543
, "build_id": "9ce628fe0dcd751ed564f0c78cb272f2f53fc4e1"
, "build_id_offset": 1392559
, "function_name": "call_function"
, "file_name": "/usr/lib64/libpython3.6m.so.1.0"
}
, { "address": 140687606511109
, "build_id": "9ce628fe0dcd751ed564f0c78cb272f2f53fc4e1"
, "build_id_offset": 1349125
, "function_name": "_PyEval_EvalFrameDefault"
, "file_name": "/usr/lib64/libpython3.6m.so.1.0"
}
, { "address": 140687606555602
, "build_id": "9ce628fe0dcd751ed564f0c78cb272f2f53fc4e1"
, "build_id_offset": 1393618
, "function_name": "PyEval_EvalCodeEx"
, "file_name": "/usr/lib64/libpython3.6m.so.1.0"
}
, { "address": 140687606558811
, "build_id": "9ce628fe0dcd751ed564f0c78cb272f2f53fc4e1"
, "build_id_offset": 1396827
, "function_name": "PyEval_EvalCode"
, "file_name": "/usr/lib64/libpython3.6m.so.1.0"
}
, { "address": 140687607117374
, "build_id": "9ce628fe0dcd751ed564f0c78cb272f2f53fc4e1"
, "build_id_offset": 1955390
, "function_name": "run_mod"
, "file_name": "/usr/lib64/libpython3.6m.so.1.0"
}
, { "address": 140687605718994
, "build_id": "9ce628fe0dcd751ed564f0c78cb272f2f53fc4e1"
, "build_id_offset": 557010
, "function_name": "PyRun_FileExFlags"
, "file_name": "/usr/lib64/libpython3.6m.so.1.0"
}
, { "address": 140687605719954
, "build_id": "9ce628fe0dcd751ed564f0c78cb272f2f53fc4e1"
, "build_id_offset": 557970
, "function_name": "PyRun_SimpleFileExFlags"
, "file_name": "/usr/lib64/libpython3.6m.so.1.0"
}
, { "address": 140687607144204
, "build_id": "9ce628fe0dcd751ed564f0c78cb272f2f53fc4e1"
, "build_id_offset": 1982220
, "function_name": "Py_Main"
, "file_name": "/usr/lib64/libpython3.6m.so.1.0"
}
, { "address": 4197017
, "build_id": "59fb7777d83033efb7a01fe18b93aaa422cb7e80"
, "build_id_offset": 2713
, "function_name": "main"
, "file_name": "/usr/bin/python3.6"
} ]
} ]
}
Let me know if there's any more information I should provide.
First of all, thanks for making your work available to all of us!
I'm currently working on adding type hints to a project that uses the noise
package. Since most of the functions & methods in this package - especially the ones defined in extension modules - do not make use of Python's dynamic typing, it seems possible and useful to add type hints here, aswell.
PEP 561 defines how to distribute type information with a python package, the documentation for mypy gives a good summary:
<packagename>-stubs
can be createdI'd be willing to do all the work.
If you are in favor of adding type hints to the noise
package, which way would you prefer, inline or as stub files? If you're opposed to adding type hints, would you mind if I create a noise-stubs
package and publish it to PyPI?
Hello,
There are seg faults in a lot of cases when specifying high coordinates. For example:
Python 2.7.3 (default, Mar 13 2014, 11:03:55)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import noise
>>> noise.__version__
'1.2.1'
>>> noise.pnoise1(2382.79792381, octaves=5, base=8898)
zsh: segmentation fault python
Could you add a function to get Tileable 2D Simplex noise? (possibly noise2 to TileableNoise)
According to the following link, one can use 4D Noise for that: http://gamedev.stackexchange.com/a/23639
Thank you very much! :)
while running a python script getting this error. Can anybody help?
Hello, I recently wanted to move and use pypy3 but when I want to import the nosie lib I got the same message as the isssue #21
the problem doesn't comes from pypy3 but still
"
Traceback (most recent call last):
File "", line 1, in
File "C:\pypy3.6-v7.3.0-win32\lib-python\3\noise_init_.py", line 12, in
from . import _perlin, _simplex
ImportError: cannot import name '_perlin'
"
I tried moving files into my project, moving the noise directory to another location also try to install it with the setup.py but doesn't work too. And finaly I tried using the wheel to install the module but it won't work anyways.
btw I remember having problems using this lib to with classic python 3.7
i'm on windows 10
i use PyPy 7.3.0 with MSC v.1911 32 bit
sorry for the bad english
Hi,
this library fails to work if installed with pip
.
Steps to reproduce:
pip install noise
;import noise
;Error:
In [1]: import noise
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-d7ad5b8bb109> in <module>()
----> 1 import noise
/home/myuser/.virtualenvs/tesst/lib/python3.5/site-packages/noise/__init__.py in <module>()
10 __version__ = "1.2.1"
11
---> 12 from . import _perlin, _simplex
13
14 snoise2 = _simplex.noise2
ImportError: /home/myuser/.virtualenvs/test/lib/python3.5/site-packages/noise/_perlin.so: Undefined symbol "grad1"
In [2]: help(noise)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-2-3c38e3ae2f92> in <module>()
----> 1 help(noise)
NameError: name 'noise' is not defined
I tried to manually build the library with python setup.py install
, yet it fails as the package distributed with pip doesn't have the C source code: it is shipped with the already compiled libraries!
System:
I've noticed the latest version of the package is not uploaded to pypi - coming here as I've also had the issue with the segfault on signal.snoise4 function.
Would you mind uploading the latest version? Not sure if I can do anything myself here.
Thanks!
$ pip2 install --user --force-reinstall --ignore-installed --no-binary :all: noise
Collecting noise
Using cached noise-1.2.2.tar.gz
Skipping bdist_wheel for noise, due to binaries being disabled for it.
Installing collected packages: noise
Running setup.py install for noise ... done
Successfully installed noise-1.2.2
$ python2
Python 2.7.13 (default, May 8 2017, 19:39:57)
[GCC 6.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import noise
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/klausman/.local/lib64/python2.7/site-packages/noise/__init__.py", line 12, in <module>
from . import _perlin, _simplex
ImportError: /home/klausman/.local/lib64/python2.7/site-packages/noise/_perlin.so: undefined symbol: grad2
>>>
Hi, I wanted to use this library for a game and cant seem to find a way to pass a seed to it. I want to be able to generate a world based off of a seed that a player would pass in (this would let them make the same world again in the future by passing the same seed in). Is there a way to do this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.