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

ShKernelPostImpl.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_KERNELPOSTIMPL_HPP 00028 #define SHUTIL_KERNELPOSTIMPL_HPP 00029 00030 #include <sstream> 00031 #include "ShSyntax.hpp" 00032 #include "ShPosition.hpp" 00033 #include "ShManipulator.hpp" 00034 #include "ShAlgebra.hpp" 00035 #include "ShProgram.hpp" 00036 #include "ShNibbles.hpp" 00037 #include "ShKernelPost.hpp" 00038 #include "ShFunc.hpp" 00039 00044 namespace ShUtil { 00045 00046 using namespace SH; 00047 00048 template<typename T> 00049 ShProgram shHalftone(const ShBaseTexture2D<T> &tex) { 00050 ShProgram kernel = SH_BEGIN_FRAGMENT_PROGRAM { 00051 typename T::InputType SH_NAMEDECL(in, "result"); 00052 ShInputTexCoord2f SH_NAMEDECL(tc, "texcoord"); 00053 00054 typename T::OutputType SH_NAMEDECL(out, "result"); 00055 00056 // TODO rotate color components... 00057 // TODO decide whether this frac should stay 00058 out = in > tex(frac(tc)); 00059 } SH_END; 00060 return kernel; 00061 } 00062 00063 template<int N, typename T> 00064 ShProgram shNoisify(bool useTexture) { 00065 ShProgram kernel = SH_BEGIN_FRAGMENT_PROGRAM { 00066 ShInputAttrib1f SH_DECL(noise_scale); 00067 typename T::InputType SH_NAMEDECL(in, "result"); 00068 ShAttrib<N, SH_INPUT, typename T::ValueType> SH_NAMEDECL(tc, "texcoord"); 00069 00070 typename T::OutputType SH_NAMEDECL(out, "result"); 00071 00072 out = in + cellnoise<T::typesize>(tc, useTexture)*noise_scale; 00073 } SH_END; 00074 return kernel; 00075 } 00076 00077 } 00078 00079 #endif

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