Added test for noise compositing
This commit is contained in:
parent
17fbaf5fce
commit
252d7e7b87
6 changed files with 21 additions and 7 deletions
|
@ -110,7 +110,7 @@ double FractalNoise::get3d(double detail, double x, double y, double z) const {
|
|||
decltype(state_level_count) i = 0;
|
||||
|
||||
while (current_height >= detail) {
|
||||
const NoiseState::NoiseOffset &offset = state.level_offsets[i];
|
||||
auto offset = state.level_offsets[i];
|
||||
|
||||
result +=
|
||||
getBase3d(offset.x + x * current_scaling, offset.y + y * current_scaling, offset.z + z * current_scaling) *
|
||||
|
|
|
@ -15,7 +15,7 @@ void NoiseNode::randomize(RandomGenerator &random) {
|
|||
noise->randomize(random);
|
||||
}
|
||||
|
||||
void NoiseNode::setConfig(double scaling, double step_scaling, double height, double step_height) {
|
||||
void NoiseNode::setConfig(double scaling, double height, double step_scaling, double step_height) {
|
||||
noise->setScaling(scaling, height);
|
||||
noise->setStep(step_scaling, step_height);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ class DEFINITIONSHARED_EXPORT NoiseNode : public DefinitionNode {
|
|||
/**
|
||||
* Set the noise configuration.
|
||||
*/
|
||||
void setConfig(double scaling, double step_scaling = 0.5, double height = 1.0, double step_height = 0.5);
|
||||
void setConfig(double scaling, double height = 1.0, double step_scaling = 0.5, double step_height = 1.0);
|
||||
|
||||
protected:
|
||||
virtual void save(PackStream *stream) const override;
|
||||
|
|
|
@ -49,8 +49,6 @@ void TexturesDefinition::applyPreset(TexturesPreset preset, RandomGenerator &ran
|
|||
layer.applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_SNOW, random);
|
||||
layer.setName("Snow");
|
||||
addLayer(layer);
|
||||
} else if (preset == TEXTURES_PRESET_CANYON) {
|
||||
/* TODO */
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,7 @@ class DEFINITIONSHARED_EXPORT TexturesDefinition : public Layers {
|
|||
typedef enum {
|
||||
TEXTURES_PRESET_FULL,
|
||||
TEXTURES_PRESET_IRELAND,
|
||||
TEXTURES_PRESET_ALPS,
|
||||
TEXTURES_PRESET_CANYON
|
||||
TEXTURES_PRESET_ALPS
|
||||
} TexturesPreset;
|
||||
void applyPreset(TexturesPreset preset, RandomGenerator &random = RandomGeneratorDefault);
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "RandomGenerator.h"
|
||||
#include "NoiseFunctionSimplex.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
|
||||
|
@ -66,6 +67,22 @@ static void testNoise() {
|
|||
filename = getFileName("noise_simplex_cache_normal");
|
||||
cout << "Rendering " << filename << "..." << endl;
|
||||
noise.getNormalTexture()->saveToFile(filename);
|
||||
|
||||
const int size = 1024;
|
||||
const double scale = 0.01;
|
||||
Texture2D pic(size, size);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
filename = getFileName("noise_simplex_compo", i);
|
||||
cout << "Rendering " << filename << "..." << endl;
|
||||
for (int x = 0; x < size; x++) {
|
||||
for (int y = 0; y < size; y++) {
|
||||
double val =
|
||||
noise.get2d(pow(0.5, to_double(i)), to_double(x) * scale, to_double(y) * scale) * 0.5 + 0.5;
|
||||
pic.setPixel(x, y, Color(val, val, val));
|
||||
}
|
||||
}
|
||||
pic.saveToFile(filename);
|
||||
}
|
||||
}
|
||||
|
||||
static void testGroundShadowQuality() {
|
||||
|
|
Loading…
Reference in a new issue