noise: move lerp into noise namespace
This commit is contained in:
parent
e525c34134
commit
912228f87b
@ -100,8 +100,6 @@ UTIL_FILES = \
|
|||||||
json/schema.hpp \
|
json/schema.hpp \
|
||||||
json/tree.cpp \
|
json/tree.cpp \
|
||||||
json/tree.hpp \
|
json/tree.hpp \
|
||||||
lerp.cpp \
|
|
||||||
lerp.hpp \
|
|
||||||
log.cpp \
|
log.cpp \
|
||||||
log.hpp \
|
log.hpp \
|
||||||
log.ipp \
|
log.ipp \
|
||||||
@ -132,6 +130,8 @@ UTIL_FILES = \
|
|||||||
noise/basis.hpp \
|
noise/basis.hpp \
|
||||||
noise/fractal.cpp \
|
noise/fractal.cpp \
|
||||||
noise/fractal.hpp \
|
noise/fractal.hpp \
|
||||||
|
noise/lerp.cpp \
|
||||||
|
noise/lerp.hpp \
|
||||||
noise/lut.cpp \
|
noise/lut.cpp \
|
||||||
noise/lut.hpp \
|
noise/lut.hpp \
|
||||||
options.cpp \
|
options.cpp \
|
||||||
|
@ -132,9 +132,9 @@ value<L>::eval (double x, double y) const {
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
namespace util {
|
namespace util {
|
||||||
namespace noise {
|
namespace noise {
|
||||||
template struct value<lerp::linear>;
|
template struct value<util::lerp::linear>;
|
||||||
template struct value<lerp::cubic>;
|
template struct value<util::lerp::cubic>;
|
||||||
template struct value<lerp::quintic>;
|
template struct value<util::lerp::quintic>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,9 +196,9 @@ gradient<L>::eval (double x, double y) const {
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
namespace util {
|
namespace util {
|
||||||
namespace noise {
|
namespace noise {
|
||||||
template struct gradient<lerp::linear>;
|
template struct gradient<util::lerp::linear>;
|
||||||
template struct gradient<lerp::cubic>;
|
template struct gradient<util::lerp::cubic>;
|
||||||
template struct gradient<lerp::quintic>;
|
template struct gradient<util::lerp::quintic>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#define __UTIL_NOISE_BASIS_HPP
|
#define __UTIL_NOISE_BASIS_HPP
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include "../lerp.hpp"
|
#include "lerp.hpp"
|
||||||
#include "../range.hpp"
|
#include "../range.hpp"
|
||||||
|
|
||||||
namespace util {
|
namespace util {
|
||||||
|
@ -91,10 +91,10 @@ util::noise::fbm<B>::eval (double x, double y) const {
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template struct util::noise::fbm<util::noise::cellular>;
|
template struct util::noise::fbm<util::noise::cellular>;
|
||||||
template struct util::noise::fbm<util::noise::gradient<lerp::linear>>;
|
template struct util::noise::fbm<util::noise::gradient<util::lerp::linear>>;
|
||||||
template struct util::noise::fbm<util::noise::gradient<lerp::quintic>>;
|
template struct util::noise::fbm<util::noise::gradient<util::lerp::quintic>>;
|
||||||
template struct util::noise::fbm<util::noise::value<lerp::linear>>;
|
template struct util::noise::fbm<util::noise::value<util::lerp::linear>>;
|
||||||
template struct util::noise::fbm<util::noise::value<lerp::quintic>>;
|
template struct util::noise::fbm<util::noise::value<util::lerp::quintic>>;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -157,8 +157,8 @@ util::noise::musgrave<B>::eval (double x, double y) const {
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template struct util::noise::musgrave<util::noise::cellular>;
|
template struct util::noise::musgrave<util::noise::cellular>;
|
||||||
template struct util::noise::musgrave<util::noise::gradient<lerp::linear>>;
|
template struct util::noise::musgrave<util::noise::gradient<util::lerp::linear>>;
|
||||||
template struct util::noise::musgrave<util::noise::gradient<lerp::quintic>>;
|
template struct util::noise::musgrave<util::noise::gradient<util::lerp::quintic>>;
|
||||||
template struct util::noise::musgrave<util::noise::value<lerp::linear>>;
|
template struct util::noise::musgrave<util::noise::value<util::lerp::linear>>;
|
||||||
template struct util::noise::musgrave<util::noise::value<lerp::quintic>>;
|
template struct util::noise::musgrave<util::noise::value<util::lerp::quintic>>;
|
||||||
|
|
||||||
|
@ -24,19 +24,19 @@
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
double
|
double
|
||||||
lerp::sigmoid (double val) {
|
util::lerp::sigmoid (double val) {
|
||||||
return -1.0 + 2.0 / (1.0 + exp (-2.0 * val));
|
return -1.0 + 2.0 / (1.0 + exp (-2.0 * val));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
double lerp::trunc (double a, double, double)
|
double util::lerp::trunc (double a, double, double)
|
||||||
{ return a; }
|
{ return a; }
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
double
|
double
|
||||||
lerp::linear (double a, double b, double weight) {
|
util::lerp::linear (double a, double b, double weight) {
|
||||||
CHECK (weight >= 0.0 && weight <= 1.0);
|
CHECK (weight >= 0.0 && weight <= 1.0);
|
||||||
return a * (1.0 - weight) + b * weight;
|
return a * (1.0 - weight) + b * weight;
|
||||||
}
|
}
|
||||||
@ -44,7 +44,7 @@ lerp::linear (double a, double b, double weight) {
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
double
|
double
|
||||||
lerp::cosine (double a, double b, double weight) {
|
util::lerp::cosine (double a, double b, double weight) {
|
||||||
CHECK (weight >= 0.0 && weight <= 1.0);
|
CHECK (weight >= 0.0 && weight <= 1.0);
|
||||||
double t = (1.0 - cos (weight * PI<double>)) * 0.5;
|
double t = (1.0 - cos (weight * PI<double>)) * 0.5;
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ lerp::cosine (double a, double b, double weight) {
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
double
|
double
|
||||||
lerp::cubic (double a, double b, double weight) {
|
util::lerp::cubic (double a, double b, double weight) {
|
||||||
CHECK (weight >= 0.0 && weight <= 1.0);
|
CHECK (weight >= 0.0 && weight <= 1.0);
|
||||||
double t = weight * weight * (3.0 - 2.0 * weight);
|
double t = weight * weight * (3.0 - 2.0 * weight);
|
||||||
return a * (1.0 - t) + b * t;
|
return a * (1.0 - t) + b * t;
|
||||||
@ -63,7 +63,7 @@ lerp::cubic (double a, double b, double weight) {
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
double
|
double
|
||||||
lerp::quintic (double a, double b, double weight) {
|
util::lerp::quintic (double a, double b, double weight) {
|
||||||
CHECK (weight >= 0.0 && weight <= 1.0);
|
CHECK (weight >= 0.0 && weight <= 1.0);
|
||||||
double t = weight * weight * weight * (weight * (weight * 6.0 - 15.0) + 10.0);
|
double t = weight * weight * weight * (weight * (weight * 6.0 - 15.0) + 10.0);
|
||||||
return a * (1.0 - t) + b * t;
|
return a * (1.0 - t) + b * t;
|
@ -14,10 +14,10 @@
|
|||||||
* Copyright 2011 Danny Robson <danny@nerdcruft.net>
|
* Copyright 2011 Danny Robson <danny@nerdcruft.net>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __UTIL_LERP_HPP
|
#ifndef __UTIL_NOISE_LERP_HPP
|
||||||
#define __UTIL_LERP_HPP
|
#define __UTIL_NOISE_LERP_HPP
|
||||||
|
|
||||||
namespace lerp {
|
namespace util { namespace lerp {
|
||||||
double sigmoid (double val);
|
double sigmoid (double val);
|
||||||
|
|
||||||
double linear (double a, double b, double weight);
|
double linear (double a, double b, double weight);
|
||||||
@ -25,6 +25,6 @@ namespace lerp {
|
|||||||
double cubic (double a, double b, double weight);
|
double cubic (double a, double b, double weight);
|
||||||
double quintic (double a, double b, double weight);
|
double quintic (double a, double b, double weight);
|
||||||
double trunc (double a, double b, double weight);
|
double trunc (double a, double b, double weight);
|
||||||
}
|
} }
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -1,6 +1,6 @@
|
|||||||
#include "image.hpp"
|
#include "image.hpp"
|
||||||
#include "noise.hpp"
|
#include "noise.hpp"
|
||||||
#include "lerp.hpp"
|
#include "noise/lerp.hpp"
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
@ -11,7 +11,9 @@ main (void)
|
|||||||
//using basis_t = util::noise::gradient<lerp_t>;
|
//using basis_t = util::noise::gradient<lerp_t>;
|
||||||
//using noise_t = util::noise::fbm<basis_t>;
|
//using noise_t = util::noise::fbm<basis_t>;
|
||||||
|
|
||||||
using noise_t = util::noise::fbm<util::noise::gradient<lerp::quintic>>;
|
//using noise_t = util::noise::fbm<util::noise::gradient<util::lerp::quintic>>;
|
||||||
|
//using noise_t = util::noise::musgrave<util::noise::gradient<util::lerp::quintic>>;
|
||||||
|
using noise_t = util::noise::fbm<util::noise::cellular>;
|
||||||
|
|
||||||
util::noise::fill (img, noise_t {});
|
util::noise::fill (img, noise_t {});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user