From c8953fa2e1d342fb4dfb4569db5659faa8673a65 Mon Sep 17 00:00:00 2001 From: psperl Date: Wed, 16 Jul 2008 05:01:11 +0000 Subject: [PATCH] Noise Implementation Improved git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@1104 6778bc44-b910-0410-a7a0-be141de4315d --- src/projectM-engine/PerlinNoise.cpp | 2 +- src/projectM-engine/Renderer.cpp | 12 +++++++++++- src/projectM-engine/Renderer.hpp | 1 + src/projectM-engine/projectM.cg | 2 ++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/projectM-engine/PerlinNoise.cpp b/src/projectM-engine/PerlinNoise.cpp index b4a3a30af..b108feab3 100644 --- a/src/projectM-engine/PerlinNoise.cpp +++ b/src/projectM-engine/PerlinNoise.cpp @@ -33,7 +33,7 @@ PerlinNoise::PerlinNoise() for (int x = 0; x < 512;x++) for (int y = 0; y < 512;y++) - noise_perlin[x][y] = perlin_noise_2d(x,y,6321,7,seed2,0.5,64); + noise_perlin[x][y] = perlin_noise_2d(x,y,6321,7,seed2,0.5,128); for (int x = 0; x < 32;x++) for (int y = 0; y < 32;y++) diff --git a/src/projectM-engine/Renderer.cpp b/src/projectM-engine/Renderer.cpp index 64ac170a8..dfaf777f6 100644 --- a/src/projectM-engine/Renderer.cpp +++ b/src/projectM-engine/Renderer.cpp @@ -160,13 +160,19 @@ glTexImage2D(GL_TEXTURE_2D,0,4,256,256,0,GL_LUMINANCE,GL_FLOAT,noise.noise_mq); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glGenTextures( 1, &noise_texture_hq ); glBindTexture( GL_TEXTURE_2D, noise_texture_hq ); glTexImage2D(GL_TEXTURE_2D,0,4,256,256,0,GL_LUMINANCE,GL_FLOAT,noise.noise_hq); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); +glGenTextures( 1, &noise_texture_perlin ); +glBindTexture( GL_TEXTURE_2D, noise_texture_perlin ); +glTexImage2D(GL_TEXTURE_2D,0,4,512,512,0,GL_LUMINANCE,GL_FLOAT,noise.noise_perlin); +glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); +glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + + glGenTextures( 1, &noise_texture_lq_vol ); glBindTexture( GL_TEXTURE_3D, noise_texture_lq_vol ); glTexImage3D(GL_TEXTURE_3D,0,4,32,32,32,0,GL_LUMINANCE,GL_FLOAT,noise.noise_lq_vol); @@ -459,6 +465,9 @@ void Renderer::SetupCgVariables(CGprogram program, const Pipeline &pipeline, con cgGLSetTextureParameter(cgGetNamedParameter(program, "sampler_noise_lq"),noise_texture_lq); cgGLEnableTextureParameter(cgGetNamedParameter(program, "sampler_noise_lq")); + cgGLSetTextureParameter(cgGetNamedParameter(program, "sampler_noise_perlin"),noise_texture_perlin); + cgGLEnableTextureParameter(cgGetNamedParameter(program, "sampler_noise_perlin")); + cgGLSetTextureParameter(cgGetNamedParameter(program, "sampler_noisevol_hq"),noise_texture_hq_vol); cgGLEnableTextureParameter(cgGetNamedParameter(program, "sampler_noisevol_hq")); @@ -484,6 +493,7 @@ void Renderer::SetupCgVariables(CGprogram program, const Pipeline &pipeline, con cgGLSetParameter4f(cgGetNamedParameter(program, "texsize_noise_lq"), 256, 256,1.0/(float)256,1.0/(float)256); cgGLSetParameter4f(cgGetNamedParameter(program, "texsize_noise_mq"), 64, 64,1.0/(float)64,1.0/(float)64); cgGLSetParameter4f(cgGetNamedParameter(program, "texsize_noise_hq"), 32, 32,1.0/(float)32,1.0/(float)32); + cgGLSetParameter4f(cgGetNamedParameter(program, "texsize_noise_perlin"), 512, 512,1.0/(float)512,1.0/(float)512); cgGLSetParameter4f(cgGetNamedParameter(program, "texsize_noise_lq_lite"), 32, 32,1.0/(float)32,1.0/(float)32); } diff --git a/src/projectM-engine/Renderer.hpp b/src/projectM-engine/Renderer.hpp index 0dd675596..6644dbf31 100644 --- a/src/projectM-engine/Renderer.hpp +++ b/src/projectM-engine/Renderer.hpp @@ -126,6 +126,7 @@ private: GLuint noise_texture_lq; GLuint noise_texture_mq; GLuint noise_texture_hq; + GLuint noise_texture_perlin; GLuint noise_texture_lq_vol; GLuint noise_texture_hq_vol; diff --git a/src/projectM-engine/projectM.cg b/src/projectM-engine/projectM.cg index 437ed03c1..ed8086278 100644 --- a/src/projectM-engine/projectM.cg +++ b/src/projectM-engine/projectM.cg @@ -53,6 +53,7 @@ uniform sampler2D sampler_noise_lq; uniform sampler2D sampler_noise_lq_lite; uniform sampler2D sampler_noise_mq; uniform sampler2D sampler_noise_hq; +uniform sampler2D sampler_noise_perlin; uniform sampler3D sampler_noisevol_lq; uniform sampler3D sampler_noisevol_hq; @@ -63,6 +64,7 @@ uniform sampler2D sampler_blur3; float4 texsize_noise_lq; float4 texsize_noise_mq; float4 texsize_noise_hq; +float4 texsize_noise_perlin; float4 texsize_noise_lq_lite; float4 _qa;