diff --git a/src/projectM-engine/PerlinNoise.cpp b/src/projectM-engine/PerlinNoise.cpp index 28b934b99..0a2f057d9 100644 --- a/src/projectM-engine/PerlinNoise.cpp +++ b/src/projectM-engine/PerlinNoise.cpp @@ -7,37 +7,30 @@ #include "PerlinNoise.hpp" #include +#include PerlinNoise::PerlinNoise() { for (int x = 0; x < 256;x++) for (int y = 0; y < 256;y++) - noise_lq[x][y] = Noise(x,y); + noise_lq[x][y] = InterpolatedNoise(x,y); for (int x = 0; x < 32;x++) for (int y = 0; y < 32;y++) noise_lq_lite[x][y] = Noise(x,y); - int scale = 4; - int width = 12413; - int seed = 61; + + int seed = rand(); for (int x = 0; x < 256;x++) for (int y = 0; y < 256;y++) - { + noise_mq[x][y] = perlin_noise_loop(x,y,12413,7,seed,0.5,32); - float disp1= perlin_noise(x*scale,y*scale,width,1,seed,100); - float disp2= perlin_noise(x*scale,y*scale,width,1,seed,25); - float disp3= perlin_noise(x*scale,y*scale,width,1,seed,12.5); - float disp4= perlin_noise(x*scale,y*scale,width,1,seed,6.25); - float disp5= perlin_noise(x*scale,y*scale,width,1,seed,3.125); - float disp6= perlin_noise(x*scale,y*scale,width,1,seed,1.56); - - noise_hq[x][y] = disp1+(disp2*.25)+(disp3*.125)+(disp4*.0625)+(disp5*.03125)+(disp6*.0156); + for (int x = 0; x < 256;x++) + for (int y = 0; y < 256;y++) + noise_hq[x][y] = perlin_noise_loop(x,y,12413,7,seed,0.5,64); - //noise_hq[x][y] = perlin_noise_2D(x,y,5,0.5); - } } diff --git a/src/projectM-engine/PerlinNoise.hpp b/src/projectM-engine/PerlinNoise.hpp index d6fdb7712..fc2c15fb9 100644 --- a/src/projectM-engine/PerlinNoise.hpp +++ b/src/projectM-engine/PerlinNoise.hpp @@ -28,12 +28,11 @@ public: private: - static inline float Noise(int x) + static inline float Noise( int x) { - int n = (x<<13) ^ x; - return ( 1.0 - ( (n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0); - - } + x = (x<<13)^x; + return (((x * (x * x * 15731 + 789221) + 1376312589) & 0x7fffffff) / 2147483648.0); + } static inline float Noise(int x, int y) { @@ -45,8 +44,8 @@ private: static inline float cos_interp(float a, float b, float x) { - int ft = x * 3.1415927; - int f = (1 - cos(ft)) * .5; + float ft = x * 3.1415927; + float f = (1 - cos(ft)) * .5; return a*(1-f) + b*f; } @@ -111,32 +110,44 @@ private: } - static inline float perlin_noise(float x,float y, int width, int octaves, int seed, float periode){ + static inline float perlin_noise(float x,float y, int width, int seed, float periode){ float a,b,value,freq,tam_pas,zone_x,zone_y; - int s,box,num,step_x,step_y; - int amplitude=1; + int box,num,step_x,step_y; + int noisedata; - freq=1/(float)(periode); + freq=1/(float)(periode); - for ( s=0;stexsize, renderTarget->texsize, 1/(float)renderTarget->texsize,1/(float)renderTarget->texsize); cgGLSetParameter4f(cgGetNamedParameter(program, "aspect"), aspect,1,1/aspect,1); - cgGLSetTextureParameter(cgGetNamedParameter(program, "sampler_noise_lq"),noise_texture_lq_lite); + cgGLSetTextureParameter(cgGetNamedParameter(program, "sampler_noise_lq"),noise_texture_lq); cgGLEnableTextureParameter(cgGetNamedParameter(program, "sampler_noise_lq")); cgGLSetTextureParameter(cgGetNamedParameter(program, "sampler_noise_lq_lite"),noise_texture_lq_lite); @@ -438,8 +438,6 @@ void Renderer::RenderFrame(const Pipeline* pipeline, const PipelineContext &pipe cgGLBindProgram(myCgWarpProgram); checkForCgError("binding warp program"); - - SetupCgVariables(myCgWarpProgram, pipelineContext); }