tahoma2d/toonz/sources/stdfx/iwa_noise1234.h

65 lines
2.3 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
/*-------------------------------------------------------------
iwa_noise1234.h
Identical to a public domain code "noise1234.h" by Stefan Gustavson.
Just changed file name for handling of files.
-------------------------------------------------------------*/
/*-- The original code starts here --*/
// Noise1234
// Author: Stefan Gustavson (stegu@itn.liu.se)
//
// This library is public domain software, released by the author
// into the public domain in February 2011. You may do anything
// you like with it. You may even remove all attributions,
// but of course I'd appreciate it if you kept my name somewhere.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
/** \file
2016-06-15 18:43:10 +12:00
\brief Declares the Noise1234 class for producing Perlin noise.
\author Stefan Gustavson (stegu@itn.liu.se)
2016-03-19 06:57:51 +13:00
*/
/*
* This is a clean, fast, modern and free Perlin noise class in C++.
* Being a stand-alone class with no external dependencies, it is
* highly reusable without source code modifications.
*
* Note:
* Replacing the "float" type with "double" can actually make this run faster
* on some platforms. A templatized version of Noise1234 could be useful.
*/
2016-06-15 18:43:10 +12:00
class Noise1234 {
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
Noise1234() {}
~Noise1234() {}
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
/** 1D, 2D, 3D and 4D float Perlin noise, SL "noise()"
*/
static float noise(float x);
static float noise(float x, float y);
static float noise(float x, float y, float z);
static float noise(float x, float y, float z, float w);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
/** 1D, 2D, 3D and 4D float Perlin periodic noise, SL "pnoise()"
*/
static float pnoise(float x, int px);
static float pnoise(float x, float y, int px, int py);
static float pnoise(float x, float y, float z, int px, int py, int pz);
static float pnoise(float x, float y, float z, float w, int px, int py,
int pz, int pw);
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
static unsigned char perm[];
static float grad(int hash, float x);
static float grad(int hash, float x, float y);
static float grad(int hash, float x, float y, float z);
static float grad(int hash, float x, float y, float z, float t);
2016-03-19 06:57:51 +13:00
};