From 9d6fe33bea0f070356d02a9196e9dfbfa3d0cf8d Mon Sep 17 00:00:00 2001 From: Comment Date: Tue, 15 Oct 2013 00:49:21 -0700 Subject: noise node --- rotord/src/nodes_maths.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'rotord/src/nodes_maths.h') diff --git a/rotord/src/nodes_maths.h b/rotord/src/nodes_maths.h index 07f111b..2696b2e 100644 --- a/rotord/src/nodes_maths.h +++ b/rotord/src/nodes_maths.h @@ -6,6 +6,8 @@ #include #include "Poco/Logger.h" +using namespace noise; + namespace Rotor { #define COMPARISON_Equal 1 #define COMPARISON_Not_equal 2 @@ -233,22 +235,27 @@ namespace Rotor { description="Fractal noise (seedable)"; create_signal_input("signal","Signal"); create_parameter("seed","number","Seed value","Seed",1.0f); + create_parameter("octaves","number","Octaves of noise","octaves",6.0f); + create_parameter("frequency","number","Frequency of noise","frequency",1.0f); + create_parameter("scale","number","scale of noise","scale",1.0f); UID="28b3c154-2d0b-11e3-bdf2-1b9b2678a2f6"; }; Noise(map &settings):Noise() { base_settings(settings); - seed=find_setting(settings,"seed",0); }; Noise* clone(map &_settings) { return new Noise(_settings);}; const float output(const Time_spec &time) { - uint32_t seed=Seed+parameters["seed"]->value; - //hash the integer part and add the fractional part back on - float o=inputs[0]->get(time); - uint32_t m=(int)o; - return ((float)(fnv1a(m,seed)%((uint32_t)time.duration)))+(o-m); + perlin.SetOctaveCount(parameters["octaves"]->value); + perlin.SetFrequency(parameters["frequency"]->value); + perlin.SetSeed(Seed+parameters["seed"]->value); + if (inputs[0]->connection){ + return perlin.GetValue(inputs[0]->get(time),0,0)*parameters["scale"]->value; + } + return perlin.GetValue(time.time,0,0)*parameters["scale"]->value; } uint32_t seed; private: + module::RidgedMulti perlin; }; } -- cgit v1.2.3