fix pn clouds ino fx
This commit is contained in:
parent
d8daf0e209
commit
83d15fe102
3 changed files with 29 additions and 30 deletions
|
@ -9,7 +9,7 @@ double perlin_noise_3d_(const double x, const double y, const double z,
|
|||
,
|
||||
const double persistence // Not 0
|
||||
// 1/4 or 1/2 or 1/sqrt(3) or 1/sqrt(2) or 1 or ...
|
||||
) {
|
||||
) {
|
||||
double total = 0;
|
||||
Noise1234 pn;
|
||||
for (int ii = octaves_start; ii <= octaves_end; ++ii) {
|
||||
|
@ -25,14 +25,14 @@ double perlin_noise_minmax_(const int octaves_start // 0<=
|
|||
,
|
||||
const double persistence // Not 0
|
||||
// 1/4 or 1/2 or 1/sqrt(3) or 1/sqrt(2) or 1 or ...
|
||||
) {
|
||||
) {
|
||||
double total = 0;
|
||||
for (int ii = octaves_start; ii <= octaves_end; ++ii) {
|
||||
total += pow(persistence, ii);
|
||||
}
|
||||
return total;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
//--------------------------------------------------------------------
|
||||
#include <stdexcept> // std::domain_error(-)
|
||||
#include <limits> // std::numeric_limits
|
||||
|
@ -40,10 +40,8 @@ double perlin_noise_minmax_(const int octaves_start // 0<=
|
|||
#include "igs_perlin_noise.h"
|
||||
namespace {
|
||||
template <class T>
|
||||
void change_(T *image_array, const int height // pixel
|
||||
,
|
||||
const int width // pixel
|
||||
,
|
||||
void change_(T *image_array, const int height, const int width,
|
||||
const int wrap, // pixel
|
||||
const int channels, const bool alpha_rendering_sw,
|
||||
const double a11 // geometry of 2D affine transformation
|
||||
,
|
||||
|
@ -54,7 +52,7 @@ void change_(T *image_array, const int height // pixel
|
|||
const int octaves_end // 0<=
|
||||
,
|
||||
const double persistence // Not 0
|
||||
) {
|
||||
) {
|
||||
const int max_div = std::numeric_limits<T>::max();
|
||||
const int max_div_2 = max_div / 2;
|
||||
// 255 / 2 --> 127
|
||||
|
@ -80,8 +78,10 @@ void change_(T *image_array, const int height // pixel
|
|||
perlin_noise_minmax_(octaves_start, octaves_end, persistence);
|
||||
|
||||
using namespace igs::image::rgba;
|
||||
T *image_crnt = image_array;
|
||||
T *image_crnt;
|
||||
T *image_scanline = image_array;
|
||||
for (int yy = 0; yy < height; ++yy) {
|
||||
image_crnt = image_scanline;
|
||||
for (int xx = 0; xx < width; ++xx, image_crnt += channels) {
|
||||
const T val = static_cast<T>(
|
||||
perlin_noise_3d_(xx * a11 + yy * a12 + a13, xx * a21 + yy * a22 + a23,
|
||||
|
@ -96,15 +96,14 @@ void change_(T *image_array, const int height // pixel
|
|||
}
|
||||
}
|
||||
}
|
||||
image_scanline += channels * wrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
// #include "igs_geometry2d.h"
|
||||
void igs::perlin_noise::change(
|
||||
unsigned char *image_array, const int height // pixel
|
||||
,
|
||||
const int width // pixel
|
||||
,
|
||||
unsigned char *image_array, const int height, const int width,
|
||||
const int wrap, // pixel
|
||||
const int channels, const int bits, const bool alpha_rendering_sw,
|
||||
const double a11 // geometry of 2D affine transformation
|
||||
,
|
||||
|
@ -114,17 +113,18 @@ void igs::perlin_noise::change(
|
|||
const int octaves_end // 0...
|
||||
,
|
||||
const double persistence // not 0
|
||||
) {
|
||||
) {
|
||||
// igs::geometry2d::affine af(a11 , a12 , a13 , a21 , a22 , a23);
|
||||
// igs::geometry2d::translate();
|
||||
|
||||
if (std::numeric_limits<unsigned char>::digits == bits) {
|
||||
change_(image_array, height, width, channels, alpha_rendering_sw, a11, a12,
|
||||
a13, a21, a22, a23, zz, octaves_start, octaves_end, persistence);
|
||||
change_(image_array, height, width, wrap, channels, alpha_rendering_sw, a11,
|
||||
a12, a13, a21, a22, a23, zz, octaves_start, octaves_end,
|
||||
persistence);
|
||||
} else if (std::numeric_limits<unsigned short>::digits == bits) {
|
||||
change_(reinterpret_cast<unsigned short *>(image_array), height, width,
|
||||
channels, alpha_rendering_sw, a11, a12, a13, a21, a22, a23, zz,
|
||||
octaves_start, octaves_end, persistence);
|
||||
wrap, channels, alpha_rendering_sw, a11, a12, a13, a21, a22, a23,
|
||||
zz, octaves_start, octaves_end, persistence);
|
||||
} else {
|
||||
throw std::domain_error("Bad bits,Not uchar/ushort");
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace perlin_noise {
|
|||
IGS_PERLIN_NOISE_EXPORT void change(
|
||||
unsigned char *image_array, const int height // pixel
|
||||
,
|
||||
const int width // pixel
|
||||
const int width, const int wrap // pixel
|
||||
,
|
||||
const int channels, const int bits, const bool alpha_rendering_sw = true
|
||||
|
||||
|
@ -28,8 +28,8 @@ IGS_PERLIN_NOISE_EXPORT void change(
|
|||
const int octaves_end = 9 // 0...
|
||||
,
|
||||
const double persistence = 1. / 1.7320508 // not 0
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
} // namespace igs
|
||||
|
||||
#endif /* !igs_perlin_noise_h */
|
||||
|
|
|
@ -67,15 +67,14 @@ void fx_(TRasterP in_ras, const double zz, const int octaves,
|
|||
const double persistance, const bool alpha_rendering_sw,
|
||||
const double a11, const double a12, const double a13, const double a21,
|
||||
const double a22, const double a23) {
|
||||
igs::perlin_noise::change(
|
||||
in_ras->getRawData() // BGRA
|
||||
,
|
||||
in_ras->getLy(), in_ras->getLx() // =in_ras->getWrap()???
|
||||
,
|
||||
ino::channels(), ino::bits(in_ras), alpha_rendering_sw, a11, a12, a13,
|
||||
a21, a22, a23, zz, 0, octaves, persistance);
|
||||
}
|
||||
igs::perlin_noise::change(in_ras->getRawData() // BGRA
|
||||
,
|
||||
in_ras->getLy(), in_ras->getLx(), in_ras->getWrap(),
|
||||
ino::channels(), ino::bits(in_ras),
|
||||
alpha_rendering_sw, a11, a12, a13, a21, a22, a23,
|
||||
zz, 0, octaves, persistance);
|
||||
}
|
||||
} // namespace
|
||||
//------------------------------------------------------------
|
||||
void ino_pn_clouds::doCompute(TTile &tile, double frame,
|
||||
const TRenderSettings &rend_sets) {
|
||||
|
|
Loading…
Reference in a new issue