Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | 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 #include "ShTypeInfo.hpp"
00033 
00034 // @todo type remove these later when noise becomes part of standard library 
00035 #define CT1T2 typename ShCommonType<T1, T2>::type
00036 
00037 namespace ShUtil {
00038 
00039 
00040 using namespace SH;
00041 
00050 template<int M, typename T, int P = 16>
00051 class ShNoise 
00052 {
00053   public:
00058     template<int K>
00059     static ShGeneric<M, T> perlin(const ShGeneric<K, T> &p, bool useTexture);
00060 
00062     template<int K>
00063     static ShGeneric<M, T> cellnoise(const ShGeneric<K, T> &p, bool useTexture);
00064 
00065   private:
00066     static ShAttrib<1, SH_CONST, T> constP, invP;
00067     static bool m_init;
00068     static ShArray3D<ShColor<M, SH_TEMP, T> > noiseTex; 
00069 
00070     static void init();
00071 };
00072 
00073 #ifndef WIN32
00074 
00075 // Returns summed octaves of Perlin improved noise
00076 // @{
00077 template<int N, int M, typename T>
00078 ShGeneric<N, T> perlin(const ShGeneric<M, T> &p, bool useTexture = true);
00079 
00080 template<int N, int M, int K, typename T1, typename T2>
00081 ShGeneric<N, CT1T2> perlin(const ShGeneric<M, T1> &p, const ShGeneric<K, T2> &amp, bool useTexture = true);
00082 // @}
00083 
00084 // Returns summed octaves of signed Perlin improved noise
00085 // @{
00086 template<int N, int M, typename T>
00087 ShGeneric<N, T> sperlin(const ShGeneric<M, T> &p, bool useTexture = true);
00088 
00089 template<int N, int M, int K, typename T1, typename T2>
00090 ShGeneric<N, CT1T2> sperlin(const ShGeneric<M, T1> &p, const ShGeneric<K, T2> &amp, bool useTexture = true);
00091 // @}
00092 
00093 // Returns summed octaves of cell noise 
00094 // @{
00095 template<int N, int M, typename T>
00096 ShGeneric<N, T> cellnoise(const ShGeneric<M, T> &p, bool useTexture = true);
00097 
00098 template<int N, int M, int K, typename T1, typename T2>
00099 ShGeneric<N, CT1T2> cellnoise(const ShGeneric<M, T1> &p, const ShGeneric<K, T2> &amp, 
00100     bool useTexture = true);
00101 // @}
00102 
00103 // Returns summed octaves of signed cell noise 
00104 // @{
00105 template<int N, int M, typename T>
00106 ShGeneric<N, T> scellnoise(const ShGeneric<M, T> &p, bool useTexture = true);
00107 
00108 template<int N, int M, int K, typename T1, typename T2>
00109 ShGeneric<N, CT1T2> scellnoise(const ShGeneric<M, T1> &p, const ShGeneric<K, T2> &amp,
00110     bool useTexture = true); 
00111 // @}
00112 
00113 // Returns M octaves of turbulence in N-dimensional space (currently 1 <= N <= 4,
00114 // 1 <= M <= 2, 1 <= K <= 4 is supported)
00115 // The ith octave has double the frequency of the (i-1)th octave and 
00116 // is weighted by amp(i).
00117 // 
00118 // The maximum M size supported is determined by the color depth of the noise texture.
00119 // The reason it is set at 2 right now is  
00120 //
00121 // useTexture determines whether procedureal hash is used or texture lookup
00122 // @{
00123 template<int N, int M, typename T>
00124 ShGeneric<N, T> turbulence(const ShGeneric<M, T> &p, bool useTexture = true);
00125 
00126 template<int N, int M, int K, typename T1, typename T2>
00127 ShGeneric<N, CT1T2> turbulence(const ShGeneric<M, T1> &p, const ShGeneric<K, T2> &amp, 
00128     bool useTexture = true);
00129 // @}
00130 
00134 template<int N, int M, typename T>
00135 ShGeneric<N, T> sturbulence(const ShGeneric<M, T> &p, bool useTexture = true);
00136 
00137 template<int N, int M, int K, typename T1, typename T2>
00138 ShGeneric<N, CT1T2> sturbulence(const ShGeneric<M, T1> &p, const ShGeneric<K, T2> &amp, 
00139     bool useTexture = true);
00140 // @}
00141 
00142 #endif // ifndef WIN32
00143 
00144 }
00145 #include "ShNoiseImpl.hpp" 
00146 
00147 //@todo type remove these later
00148 #undef CT1T2
00149 #endif

Generated on Mon Jan 24 18:36:33 2005 for Sh by  doxygen 1.4.1