00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00020 #ifndef SHUTIL_KERNELPOSTIMPL_HPP
00021 #define SHUTIL_KERNELPOSTIMPL_HPP
00022
00023 #include <sstream>
00024 #include "ShSyntax.hpp"
00025 #include "ShPosition.hpp"
00026 #include "ShManipulator.hpp"
00027 #include "ShAlgebra.hpp"
00028 #include "ShProgram.hpp"
00029 #include "ShNibbles.hpp"
00030 #include "ShKernelPost.hpp"
00031 #include "ShFunc.hpp"
00032
00037 namespace ShUtil {
00038
00039 using namespace SH;
00040
00041 template<typename T>
00042 ShProgram shHalftone(const ShBaseTexture2D<T> &tex) {
00043 ShProgram kernel = SH_BEGIN_FRAGMENT_PROGRAM {
00044 typename T::InputType SH_NAMEDECL(in, "result");
00045 ShInputTexCoord2f SH_NAMEDECL(tc, "texcoord");
00046
00047 typename T::OutputType SH_NAMEDECL(out, "result");
00048
00049
00050
00051 out = in > tex(frac(tc));
00052 } SH_END;
00053 return kernel;
00054 }
00055
00056 template<int N, typename T>
00057 ShProgram shNoisify(bool useTexture) {
00058 ShProgram kernel = SH_BEGIN_FRAGMENT_PROGRAM {
00059 ShInputAttrib1f SH_DECL(noise_scale);
00060 typename T::InputType SH_NAMEDECL(in, "result");
00061 ShAttrib<N, SH_INPUT, typename T::storage_type> SH_NAMEDECL(tc, "texcoord");
00062
00063 typename T::OutputType SH_NAMEDECL(out, "result");
00064
00065 out = in + cellnoise<T::typesize>(tc, useTexture)*noise_scale;
00066 } SH_END;
00067 return kernel;
00068 }
00069
00070 }
00071
00072 #endif