paysages : Noise level offsets are now fixed.
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@508 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
fad0b9941b
commit
756ff0ec99
4 changed files with 54 additions and 37 deletions
2
TODO
2
TODO
|
@ -21,8 +21,8 @@ Technology Preview 2 :
|
||||||
=> Covering texture height should inpact terrain height.
|
=> Covering texture height should inpact terrain height.
|
||||||
=> Add texture shadowing.
|
=> Add texture shadowing.
|
||||||
- Clouds should keep distance to ground.
|
- Clouds should keep distance to ground.
|
||||||
- Waves noise should not change layers offsets each time a setting is changed (layers are reconstructed currently).
|
|
||||||
- Fix rendering when inside a cloud layer, with other upper or lower layers.
|
- Fix rendering when inside a cloud layer, with other upper or lower layers.
|
||||||
|
- Make fileNew work again (call auto presets and randomize all noise offsets).
|
||||||
- Improve cloud rendering precision (and beware of precision discontinuity when rendering clouds in front of ground (shorter distance)).
|
- Improve cloud rendering precision (and beware of precision discontinuity when rendering clouds in front of ground (shorter distance)).
|
||||||
|
|
||||||
Technlogy Preview 3 :
|
Technlogy Preview 3 :
|
||||||
|
|
|
@ -283,10 +283,8 @@ void DialogNoise::addLevel()
|
||||||
|
|
||||||
level.amplitude = 0.1;
|
level.amplitude = 0.1;
|
||||||
level.wavelength = 0.1;
|
level.wavelength = 0.1;
|
||||||
level.xoffset = 0.0;
|
|
||||||
level.yoffset = 0.0;
|
noiseAddLevel(_current, level, 1);
|
||||||
level.zoffset = 0.0;
|
|
||||||
noiseAddLevel(_current, level);
|
|
||||||
|
|
||||||
revertToCurrent();
|
revertToCurrent();
|
||||||
|
|
||||||
|
@ -340,7 +338,7 @@ void DialogNoise::levelChanged(int row)
|
||||||
void DialogNoise::heightChanged(int value)
|
void DialogNoise::heightChanged(int value)
|
||||||
{
|
{
|
||||||
_current_level_params.amplitude = ((double)value) / 1000.0;
|
_current_level_params.amplitude = ((double)value) / 1000.0;
|
||||||
noiseSetLevel(_current, _current_level, _current_level_params);
|
noiseSetLevel(_current, _current_level, _current_level_params, 1);
|
||||||
previewLevel->redraw();
|
previewLevel->redraw();
|
||||||
previewTotal->redraw();
|
previewTotal->redraw();
|
||||||
}
|
}
|
||||||
|
@ -348,7 +346,7 @@ void DialogNoise::heightChanged(int value)
|
||||||
void DialogNoise::scalingChanged(int value)
|
void DialogNoise::scalingChanged(int value)
|
||||||
{
|
{
|
||||||
_current_level_params.wavelength = ((double)value) / 1000.0;
|
_current_level_params.wavelength = ((double)value) / 1000.0;
|
||||||
noiseSetLevel(_current, _current_level, _current_level_params);
|
noiseSetLevel(_current, _current_level, _current_level_params, 1);
|
||||||
previewLevel->redraw();
|
previewLevel->redraw();
|
||||||
previewTotal->redraw();
|
previewTotal->redraw();
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,7 @@ NoiseGenerator* noiseCreateGenerator()
|
||||||
result->level_count = 0;
|
result->level_count = 0;
|
||||||
result->height_offset = 0.0;
|
result->height_offset = 0.0;
|
||||||
|
|
||||||
|
noiseRandomizeOffsets(result);
|
||||||
noiseValidate(result);
|
noiseValidate(result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -215,6 +216,17 @@ void noiseValidate(NoiseGenerator* generator)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void noiseRandomizeOffsets(NoiseGenerator* generator)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < MAX_LEVEL_COUNT; i++)
|
||||||
|
{
|
||||||
|
result->levels[i].xoffset = toolsRandom();
|
||||||
|
result->levels[i].yoffset = toolsRandom();
|
||||||
|
result->levels[i].zoffset = toolsRandom();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NoiseFunction noiseGetFunction(NoiseGenerator* generator)
|
NoiseFunction noiseGetFunction(NoiseGenerator* generator)
|
||||||
{
|
{
|
||||||
return generator->function;
|
return generator->function;
|
||||||
|
@ -256,10 +268,19 @@ void noiseClearLevels(NoiseGenerator* generator)
|
||||||
noiseValidate(generator);
|
noiseValidate(generator);
|
||||||
}
|
}
|
||||||
|
|
||||||
void noiseAddLevel(NoiseGenerator* generator, NoiseLevel level)
|
void noiseAddLevel(NoiseGenerator* generator, NoiseLevel level, int protect_offsets)
|
||||||
{
|
{
|
||||||
if (generator->level_count < MAX_LEVEL_COUNT)
|
if (generator->level_count < MAX_LEVEL_COUNT)
|
||||||
{
|
{
|
||||||
|
NoiseLevel baselevel = generator->levels[generator->level_count];
|
||||||
|
|
||||||
|
if (protect_offsets)
|
||||||
|
{
|
||||||
|
level.xoffset = baselevel.xoffset;
|
||||||
|
level.yoffset = baselevel.yoffset;
|
||||||
|
level.zoffset = baselevel.zoffset;
|
||||||
|
}
|
||||||
|
|
||||||
generator->levels[generator->level_count] = level;
|
generator->levels[generator->level_count] = level;
|
||||||
generator->level_count++;
|
generator->level_count++;
|
||||||
noiseValidate(generator);
|
noiseValidate(generator);
|
||||||
|
@ -273,26 +294,17 @@ void noiseAddLevelSimple(NoiseGenerator* generator, double scaling, double minva
|
||||||
level.wavelength = scaling;
|
level.wavelength = scaling;
|
||||||
level.minvalue = minvalue;
|
level.minvalue = minvalue;
|
||||||
level.amplitude = maxvalue - minvalue;
|
level.amplitude = maxvalue - minvalue;
|
||||||
level.xoffset = toolsRandom();
|
|
||||||
level.yoffset = toolsRandom();
|
|
||||||
level.zoffset = toolsRandom();
|
|
||||||
|
|
||||||
noiseAddLevel(generator, level);
|
noiseAddLevel(generator, level, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void noiseAddLevels(NoiseGenerator* generator, int level_count, NoiseLevel start_level, double scaling_factor, double amplitude_factor, double center_factor, int randomize_offset)
|
void noiseAddLevels(NoiseGenerator* generator, int level_count, NoiseLevel start_level, double scaling_factor, double amplitude_factor, double center_factor)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < level_count; i++)
|
for (i = 0; i < level_count; i++)
|
||||||
{
|
{
|
||||||
if (randomize_offset)
|
noiseAddLevel(generator, start_level, 1);
|
||||||
{
|
|
||||||
start_level.xoffset = toolsRandom();
|
|
||||||
start_level.yoffset = toolsRandom();
|
|
||||||
start_level.zoffset = toolsRandom();
|
|
||||||
}
|
|
||||||
noiseAddLevel(generator, start_level);
|
|
||||||
start_level.minvalue += start_level.amplitude * (1.0 - amplitude_factor) * center_factor;
|
start_level.minvalue += start_level.amplitude * (1.0 - amplitude_factor) * center_factor;
|
||||||
start_level.wavelength *= scaling_factor;
|
start_level.wavelength *= scaling_factor;
|
||||||
start_level.amplitude *= amplitude_factor;
|
start_level.amplitude *= amplitude_factor;
|
||||||
|
@ -306,7 +318,7 @@ void noiseAddLevelsSimple(NoiseGenerator* generator, int level_count, double sca
|
||||||
level.wavelength = scaling;
|
level.wavelength = scaling;
|
||||||
level.minvalue = minvalue;
|
level.minvalue = minvalue;
|
||||||
level.amplitude = maxvalue - minvalue;
|
level.amplitude = maxvalue - minvalue;
|
||||||
noiseAddLevels(generator, level_count, level, 0.5, 0.5, 0.5, 1);
|
noiseAddLevels(generator, level_count, level, 0.5, 0.5, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
void noiseRemoveLevel(NoiseGenerator* generator, int level)
|
void noiseRemoveLevel(NoiseGenerator* generator, int level)
|
||||||
|
@ -335,27 +347,33 @@ int noiseGetLevel(NoiseGenerator* generator, int level, NoiseLevel* params)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void noiseSetLevel(NoiseGenerator* generator, int level, NoiseLevel params)
|
void noiseSetLevel(NoiseGenerator* generator, int index, NoiseLevel level, int protect_offsets)
|
||||||
{
|
{
|
||||||
if (level >= 0 && level < generator->level_count)
|
if (index >= 0 && index < generator->level_count)
|
||||||
{
|
{
|
||||||
generator->levels[level] = params;
|
NoiseLevel baselevel = generator->levels[index];
|
||||||
|
|
||||||
|
if (protect_offsets)
|
||||||
|
{
|
||||||
|
level.xoffset = baselevel.xoffset;
|
||||||
|
level.yoffset = baselevel.yoffset;
|
||||||
|
level.zoffset = baselevel.zoffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
generator->levels[index] = level;
|
||||||
noiseValidate(generator);
|
noiseValidate(generator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void noiseSetLevelSimple(NoiseGenerator* generator, int level, double scaling, double minvalue, double maxvalue)
|
void noiseSetLevelSimple(NoiseGenerator* generator, int index, double scaling, double minvalue, double maxvalue)
|
||||||
{
|
{
|
||||||
NoiseLevel params;
|
NoiseLevel level;
|
||||||
|
|
||||||
params.wavelength = scaling;
|
level.wavelength = scaling;
|
||||||
params.minvalue = minvalue;
|
level.minvalue = minvalue;
|
||||||
params.amplitude = maxvalue - minvalue;
|
level.amplitude = maxvalue - minvalue;
|
||||||
params.xoffset = toolsRandom();
|
|
||||||
params.yoffset = toolsRandom();
|
|
||||||
params.zoffset = toolsRandom();
|
|
||||||
|
|
||||||
noiseSetLevel(generator, level, params);
|
noiseSetLevel(generator, index, level, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void noiseNormalizeAmplitude(NoiseGenerator* generator, double minvalue, double maxvalue, int adjust_scaling)
|
void noiseNormalizeAmplitude(NoiseGenerator* generator, double minvalue, double maxvalue, int adjust_scaling)
|
||||||
|
|
|
@ -44,6 +44,7 @@ void noiseSaveGenerator(PackStream* stream, NoiseGenerator* generator);
|
||||||
void noiseLoadGenerator(PackStream* stream, NoiseGenerator* generator);
|
void noiseLoadGenerator(PackStream* stream, NoiseGenerator* generator);
|
||||||
void noiseCopy(NoiseGenerator* source, NoiseGenerator* destination);
|
void noiseCopy(NoiseGenerator* source, NoiseGenerator* destination);
|
||||||
void noiseValidate(NoiseGenerator* generator);
|
void noiseValidate(NoiseGenerator* generator);
|
||||||
|
void noiseRandomizeOffsets(NoiseGenerator* generator);
|
||||||
NoiseFunction noiseGetFunction(NoiseGenerator* generator);
|
NoiseFunction noiseGetFunction(NoiseGenerator* generator);
|
||||||
void noiseSetFunction(NoiseGenerator* generator, NoiseFunction* function);
|
void noiseSetFunction(NoiseGenerator* generator, NoiseFunction* function);
|
||||||
void noiseSetFunctionParams(NoiseGenerator* generator, NoiseFunctionAlgorithm algorithm, double ridge_factor, double curve_factor);
|
void noiseSetFunctionParams(NoiseGenerator* generator, NoiseFunctionAlgorithm algorithm, double ridge_factor, double curve_factor);
|
||||||
|
@ -51,14 +52,14 @@ void noiseForceValue(NoiseGenerator* generator, double value);
|
||||||
void noiseGetRange(NoiseGenerator* generator, double* minvalue, double* maxvalue);
|
void noiseGetRange(NoiseGenerator* generator, double* minvalue, double* maxvalue);
|
||||||
int noiseGetLevelCount(NoiseGenerator* generator);
|
int noiseGetLevelCount(NoiseGenerator* generator);
|
||||||
void noiseClearLevels(NoiseGenerator* generator);
|
void noiseClearLevels(NoiseGenerator* generator);
|
||||||
void noiseAddLevel(NoiseGenerator* generator, NoiseLevel level);
|
void noiseAddLevel(NoiseGenerator* generator, NoiseLevel level, int protect_offsets);
|
||||||
void noiseAddLevelSimple(NoiseGenerator* generator, double scaling, double minvalue, double maxvalue);
|
void noiseAddLevelSimple(NoiseGenerator* generator, double scaling, double minvalue, double maxvalue);
|
||||||
void noiseAddLevels(NoiseGenerator* generator, int level_count, NoiseLevel start_level, double scaling_factor, double amplitude_factor, double center_factor, int randomize_offset);
|
void noiseAddLevels(NoiseGenerator* generator, int level_count, NoiseLevel start_level, double scaling_factor, double amplitude_factor, double center_factor);
|
||||||
void noiseAddLevelsSimple(NoiseGenerator* generator, int level_count, double scaling, double minvalue, double maxvalue);
|
void noiseAddLevelsSimple(NoiseGenerator* generator, int level_count, double scaling, double minvalue, double maxvalue);
|
||||||
void noiseRemoveLevel(NoiseGenerator* generator, int level);
|
void noiseRemoveLevel(NoiseGenerator* generator, int level);
|
||||||
int noiseGetLevel(NoiseGenerator* generator, int level, NoiseLevel* params);
|
int noiseGetLevel(NoiseGenerator* generator, int level, NoiseLevel* params);
|
||||||
void noiseSetLevel(NoiseGenerator* generator, int level, NoiseLevel params);
|
void noiseSetLevel(NoiseGenerator* generator, int index, NoiseLevel level, int protect_offsets);
|
||||||
void noiseSetLevelSimple(NoiseGenerator* generator, int level, double scaling, double minvalue, double maxvalue);
|
void noiseSetLevelSimple(NoiseGenerator* generator, int index, double scaling, double minvalue, double maxvalue);
|
||||||
void noiseNormalizeAmplitude(NoiseGenerator* generator, double minvalue, double maxvalue, int adjust_scaling);
|
void noiseNormalizeAmplitude(NoiseGenerator* generator, double minvalue, double maxvalue, int adjust_scaling);
|
||||||
double noiseGet1DLevel(NoiseGenerator* generator, int level, double x);
|
double noiseGet1DLevel(NoiseGenerator* generator, int level, double x);
|
||||||
double noiseGet1DTotal(NoiseGenerator* generator, double x);
|
double noiseGet1DTotal(NoiseGenerator* generator, double x);
|
||||||
|
|
Loading…
Reference in a new issue