Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ShNoise.hpp

Go to the documentation of this file.
00001 // Sh: A GPU metaprogramming language. 00002 // 00003 // Copyright (c) 2003 University of Waterloo Computer Graphics Laboratory 00004 // Project administrator: Michael D. McCool 00005 // Authors: Zheng Qin, Stefanus Du Toit, Kevin Moule, Tiberiu S. Popa, 00006 // Bryan Chan, Michael D. McCool 00007 // 00008 // This software is provided 'as-is', without any express or implied 00009 // warranty. In no event will the authors be held liable for any damages 00010 // arising from the use of this software. 00011 // 00012 // Permission is granted to anyone to use this software for any purpose, 00013 // including commercial applications, and to alter it and redistribute it 00014 // freely, subject to the following restrictions: 00015 // 00016 // 1. The origin of this software must not be misrepresented; you must 00017 // not claim that you wrote the original software. If you use this 00018 // software in a product, an acknowledgment in the product documentation 00019 // would be appreciated but is not required. 00020 // 00021 // 2. Altered source versions must be plainly marked as such, and must 00022 // not be misrepresented as being the original software. 00023 // 00024 // 3. This notice may not be removed or altered from any source 00025 // distribution. 00027 #ifndef SHUTIL_NOISE_HPP 00028 #define SHUTIL_NOISE_HPP 00029 00030 #include "ShAttrib.hpp" 00031 #include "ShArray.hpp" 00032 00033 namespace ShUtil { 00034 00035 using namespace SH; 00036 00045 template<int M, typename T, int P = 16> 00046 class ShNoise 00047 { 00048 public: 00053 template<int K> 00054 static ShGeneric<M, T> perlin(const ShGeneric<K, T> &p, bool useTexture); 00055 00057 template<int K> 00058 static ShGeneric<M, T> cellnoise(const ShGeneric<K, T> &p, bool useTexture); 00059 00060 private: 00061 static ShAttrib<1, SH_CONST, T> constP, invP; 00062 static bool m_init; 00063 static ShArray3D<ShColor<M, SH_TEMP, T> > noiseTex; 00064 00065 static void init(); 00066 }; 00067 00068 // Returns summed octaves of Perlin improved noise 00069 // @{ 00070 template<int N, int M, typename T> 00071 ShGeneric<N, T> perlin(const ShGeneric<M, T> &p, bool useTexture = true); 00072 00073 template<int N, int M, int K, typename T> 00074 ShGeneric<N, T> perlin(const ShGeneric<M, T> &p, const ShGeneric<K, T> &amp, bool useTexture = true); 00075 // @} 00076 00077 // Returns summed octaves of signed Perlin improved noise 00078 // @{ 00079 template<int N, int M, typename T> 00080 ShGeneric<N, T> sperlin(const ShGeneric<M, T> &p, bool useTexture = true); 00081 00082 template<int N, int M, int K, typename T> 00083 ShGeneric<N, T> sperlin(const ShGeneric<M, T> &p, const ShGeneric<K, T> &amp, bool useTexture = true); 00084 // @} 00085 00086 // Returns summed octaves of cell noise 00087 // @{ 00088 template<int N, int M, typename T> 00089 ShGeneric<N, T> cellnoise(const ShGeneric<M, T> &p, bool useTexture = true); 00090 00091 template<int N, int M, int K, typename T> 00092 ShGeneric<N, T> cellnoise(const ShGeneric<M, T> &p, const ShGeneric<K, T> &amp, 00093 bool useTexture = true); 00094 // @} 00095 00096 // Returns summed octaves of signed cell noise 00097 // @{ 00098 template<int N, int M, typename T> 00099 ShGeneric<N, T> scellnoise(const ShGeneric<M, T> &p, bool useTexture = true); 00100 00101 template<int N, int M, int K, typename T> 00102 ShGeneric<N, T> scellnoise(const ShGeneric<M, T> &p, const ShGeneric<K, T> &amp, 00103 bool useTexture = true); 00104 // @} 00105 00106 // Returns M octaves of turbulence in N-dimensional space (currently 1 <= N <= 4, 00107 // 1 <= M <= 2, 1 <= K <= 4 is supported) 00108 // The ith octave has double the frequency of the (i-1)th octave and 00109 // is weighted by amp(i). 00110 // 00111 // The maximum M size supported is determined by the color depth of the noise texture. 00112 // The reason it is set at 2 right now is 00113 // 00114 // useTexture determines whether procedureal hash is used or texture lookup 00115 // @{ 00116 template<int N, int M, typename T> 00117 ShGeneric<N, T> turbulence(const ShGeneric<M, T> &p, bool useTexture = true); 00118 00119 template<int N, int M, int K, typename T> 00120 ShGeneric<N, T> turbulence(const ShGeneric<M, T> &p, const ShGeneric<K, T> &amp, 00121 bool useTexture = true); 00122 // @} 00123 00127 template<int N, int M, typename T> 00128 ShGeneric<N, T> sturbulence(const ShGeneric<M, T> &p, bool useTexture = true); 00129 00130 template<int N, int M, int K, typename T> 00131 ShGeneric<N, T> sturbulence(const ShGeneric<M, T> &p, const ShGeneric<K, T> &amp, 00132 bool useTexture = true); 00133 // @} 00134 } 00135 #include "ShNoiseImpl.hpp" 00136 00137 #endif

Generated on Mon Oct 18 14:17:39 2004 for Sh by doxygen 1.3.7