00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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
00057
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::storage_type> 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