paysages : Added foam to water + auto preset for water.
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@464 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
55f606bd85
commit
a95c07623c
9 changed files with 188 additions and 36 deletions
48
ChangeLog
48
ChangeLog
|
@ -1,27 +1,31 @@
|
|||
????-??-?? Technology Preview 2
|
||||
-------------------------------
|
||||
|
||||
Previews :
|
||||
* Scaling is now logarithmic (slower when zoomed).
|
||||
* Drawing now takes advantage of multiple CPU cores.
|
||||
Global :
|
||||
* Version handling in saved files.
|
||||
* Replaced old noise algorithm with Simplex Noise (up to 4 times faster).
|
||||
|
||||
3D Explorer:
|
||||
* Added ground texture and skybox.
|
||||
* Progressive rendering now takes advantage of multiple CPU cores.
|
||||
Terrain :
|
||||
* Added canvases to paint the shape directly.
|
||||
* Shadows have been improved and are now configurable.
|
||||
|
||||
Scenery :
|
||||
* Added terrain canvases to paint the shape directly.
|
||||
* Added clouds hardness to light.
|
||||
* Added sun halo control.
|
||||
* New cloud model with 2 noises : one for the global shape and one for edges.
|
||||
* Terrain shadows have been improved and are now configurable.
|
||||
* New sky model (based on Preetham's work).
|
||||
Textures :
|
||||
* New texture model (perpendicular displacement and thickness).
|
||||
* Textures ranges are now using curves.
|
||||
|
||||
Water :
|
||||
* Added foam.
|
||||
|
||||
Sky :
|
||||
* New sky model (based on Preetham's work).
|
||||
* Added sun halo control.
|
||||
|
||||
Clouds :
|
||||
* Added clouds hardness to light.
|
||||
* New cloud model with 2 noises : one for the global shape and one for edges.
|
||||
|
||||
Rendering :
|
||||
* New texture model (perpendicular displacement and thickness).
|
||||
* Added full scene antialiasing (FSAA).
|
||||
* Replaced old noise algorithm with Simplex Noise (up to 4 times faster).
|
||||
|
||||
GUI :
|
||||
* Improved curve rendering.
|
||||
|
@ -29,12 +33,18 @@ GUI :
|
|||
* Added render timer.
|
||||
* Previews locations and render params are now saved.
|
||||
* Added grid and axis labels to curve editor.
|
||||
* Added camera location to previews.
|
||||
* Added toggles and choices to configure some previews.
|
||||
* Added layer sorting and naming.
|
||||
* Automatic settings can be loaded from presets.
|
||||
|
||||
Misc :
|
||||
* Version handling in saved files.
|
||||
Previews :
|
||||
* Scaling is now logarithmic (slower when zoomed).
|
||||
* Drawing now takes advantage of multiple CPU cores.
|
||||
* Added camera location.
|
||||
* Added toggles and choices to configure some previews.
|
||||
|
||||
3D Explorer:
|
||||
* Added ground texture and skybox.
|
||||
* Progressive rendering now takes advantage of multiple CPU cores.
|
||||
|
||||
2012-04-20 Technology Preview 1
|
||||
-------------------------------
|
||||
|
|
18
TODO
18
TODO
|
@ -1,22 +1,26 @@
|
|||
Technology Preview 2 :
|
||||
- Fully move layer management from BaseForm to BaseFormLayer.
|
||||
- Replace math.h methods by optimized ones (fastfloor, fastsin...).
|
||||
- Add foam to water.
|
||||
- Replace terrain canvas editor by full sculpting editor.
|
||||
=> Add a generation dialog, with fixed resolution.
|
||||
=> Store local terrain modifications in fully dynamic canvas.
|
||||
=> Add map preview with editor area.
|
||||
=> Allow camera move and zoom.
|
||||
- Get rid of noise dialogs, for simpler settings.
|
||||
- Finalize Preetham's model usage
|
||||
=> Apply model to atmosphere (aerial perspective)
|
||||
=> Find a proper model for night sky (maybe Shirley)
|
||||
- Keep skydome lights in cache for a render.
|
||||
- Add buttons to restore "auto" default values in tabs and dialogs (with several auto presets).
|
||||
- Clouds should keep distance to ground.
|
||||
- Rethink the quality settings and detail smoothing in the distance.
|
||||
=> When quality setting is set to 10, add boost options
|
||||
=> Add detail boost (adds granularity)
|
||||
=> Add step boost (for marching algorithms)
|
||||
- Waves noise should not change layers offsets each time a setting is changed (layers are reconstructed currently).
|
||||
- Add "hardness to light" and shadow control ("minimum lighting") to material.
|
||||
|
||||
Technlogy Preview 3 :
|
||||
- Add logarithmic sliders for some float values.
|
||||
- Replace terrain canvas editor by full sculpting editor.
|
||||
=> Add a generation dialog, with fixed resolution.
|
||||
=> Store local terrain modifications in fully dynamic canvas.
|
||||
=> Add map preview with editor area.
|
||||
=> Allow camera move and zoom.
|
||||
- Improve previews.
|
||||
=> Add user markers on OSD.
|
||||
=> Add areas marking.
|
||||
|
|
|
@ -120,6 +120,10 @@ BaseForm::BaseForm(QWidget* parent, bool auto_apply, bool with_layers) : QWidget
|
|||
_button_apply->setIcon(QIcon("images/apply.png"));
|
||||
_button_apply->setEnabled(false);
|
||||
connect(_button_apply, SIGNAL(clicked()), this, SLOT(applyConfig()));
|
||||
_button_preset = addButton(tr("Load preset"));
|
||||
_button_preset->setIcon(QIcon("images/auto.png"));
|
||||
_button_preset->hide();
|
||||
connect(_button_preset, SIGNAL(clicked()), this, SLOT(presetChoiceClicked()));
|
||||
|
||||
_auto_update_previews = true;
|
||||
|
||||
|
@ -183,6 +187,16 @@ void BaseForm::configChangeEvent()
|
|||
}
|
||||
}
|
||||
|
||||
void BaseForm::autoPresetSelected(int)
|
||||
{
|
||||
for (int i = 0; i < _inputs_list.size(); i++)
|
||||
{
|
||||
_inputs_list[i]->revert();
|
||||
}
|
||||
updatePreviews();
|
||||
configChangeEvent();
|
||||
}
|
||||
|
||||
void BaseForm::revertConfig()
|
||||
{
|
||||
for (int i = 0; i < _inputs_list.size(); i++)
|
||||
|
@ -322,6 +336,21 @@ void BaseForm::layerListChanged()
|
|||
_button_revert->setEnabled(changed);
|
||||
}
|
||||
|
||||
void BaseForm::presetChoiceClicked()
|
||||
{
|
||||
bool ok;
|
||||
QString item = QInputDialog::getItem(this, tr("Choose a preset"), tr("Preset settings : "), _preset_list, 0, false, &ok);
|
||||
|
||||
if (ok && !item.isEmpty())
|
||||
{
|
||||
int preset = _preset_list.indexOf(item);
|
||||
if (preset >= 0)
|
||||
{
|
||||
autoPresetSelected(preset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BaseForm::addPreview(BasePreview* preview, QString label)
|
||||
{
|
||||
QLabel* label_widget;
|
||||
|
@ -342,6 +371,12 @@ QPushButton* BaseForm::addButton(QString label)
|
|||
return button;
|
||||
}
|
||||
|
||||
void BaseForm::addAutoPreset(QString label)
|
||||
{
|
||||
_preset_list.append(label);
|
||||
_button_preset->show();
|
||||
}
|
||||
|
||||
BaseInput* BaseForm::addInput(BaseInput* input)
|
||||
{
|
||||
int row_height = 30;
|
||||
|
|
|
@ -36,6 +36,7 @@ public slots:
|
|||
|
||||
protected slots:
|
||||
virtual void configChangeEvent();
|
||||
virtual void autoPresetSelected(int preset);
|
||||
|
||||
private slots:
|
||||
void rebuildLayerList();
|
||||
|
@ -45,10 +46,12 @@ private slots:
|
|||
void layerDownClicked();
|
||||
void layerRenameClicked();
|
||||
void layerListChanged();
|
||||
void presetChoiceClicked();
|
||||
|
||||
protected:
|
||||
void addPreview(BasePreview* preview, QString label);
|
||||
QPushButton* addButton(QString label);
|
||||
void addAutoPreset(QString label);
|
||||
BaseInput* addInput(BaseInput* input);
|
||||
BaseInput* addInputInt(QString label, int* value, int min, int max, int small_step, int large_step);
|
||||
BaseInput* addInputDouble(QString label, double* value, double min, double max, double small_step, double large_step);
|
||||
|
@ -83,6 +86,7 @@ private:
|
|||
QWidget* _buttons;
|
||||
QPushButton* _button_apply;
|
||||
QPushButton* _button_revert;
|
||||
QPushButton* _button_preset;
|
||||
|
||||
QWidget* _previews;
|
||||
QVector<BasePreview*> _previews_list;
|
||||
|
@ -90,6 +94,8 @@ private:
|
|||
|
||||
QVector<BaseInput*> _inputs_list;
|
||||
|
||||
QStringList _preset_list;
|
||||
|
||||
bool _with_layers;
|
||||
QComboBox* _layer_list;
|
||||
int _layer_count;
|
||||
|
|
|
@ -206,12 +206,14 @@ private:
|
|||
FormWater::FormWater(QWidget *parent):
|
||||
BaseForm(parent)
|
||||
{
|
||||
addAutoPreset(tr("Standard water"));
|
||||
|
||||
_definition = waterCreateDefinition();
|
||||
|
||||
previewCoverage = new PreviewWaterCoverage(this);
|
||||
previewColor = new PreviewWaterColor(this);
|
||||
addPreview(previewCoverage, QString(tr("Coverage preview")));
|
||||
addPreview(previewColor, QString(tr("Rendered preview")));
|
||||
addPreview(previewCoverage, tr("Coverage preview"));
|
||||
addPreview(previewColor, tr("Rendered preview"));
|
||||
|
||||
addInputDouble(tr("Height"), &_definition.height, -10.0, 10.0, 0.1, 1.0);
|
||||
addInputMaterial(tr("Surface material"), &_definition.material);
|
||||
|
@ -224,6 +226,8 @@ FormWater::FormWater(QWidget *parent):
|
|||
addInputDouble(tr("Waves height"), &_definition.waves_height, 0.0, 2.0, 0.02, 0.2);
|
||||
addInputDouble(tr("Waves detail"), &_definition.detail_height, 0.0, 0.3, 0.003, 0.03);
|
||||
addInputDouble(tr("Waves turbulence"), &_definition.turbulence, 0.0, 0.5, 0.005, 0.05);
|
||||
addInputDouble(tr("Foam coverage"), &_definition.foam_coverage, 0.0, 1.0, 0.01, 0.1);
|
||||
addInputMaterial(tr("Foam material"), &_definition.foam_material);
|
||||
|
||||
revertConfig();
|
||||
}
|
||||
|
@ -245,3 +249,13 @@ void FormWater::configChangeEvent()
|
|||
waterValidateDefinition(&_definition);
|
||||
BaseForm::configChangeEvent();
|
||||
}
|
||||
|
||||
void FormWater::autoPresetSelected(int preset)
|
||||
{
|
||||
if (preset == (int)WATER_PRESET_STD)
|
||||
{
|
||||
waterAutoPreset(&_definition, WATER_PRESET_STD);
|
||||
}
|
||||
BaseForm::autoPresetSelected(preset);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ public slots:
|
|||
|
||||
protected slots:
|
||||
virtual void configChangeEvent();
|
||||
virtual void autoPresetSelected(int preset);
|
||||
|
||||
private:
|
||||
BasePreview* previewCoverage;
|
||||
|
|
BIN
images/auto.png
Normal file
BIN
images/auto.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
|
@ -24,6 +24,9 @@ void waterSave(PackStream* stream, WaterDefinition* definition)
|
|||
packWriteDouble(stream, &definition->waves_height);
|
||||
packWriteDouble(stream, &definition->detail_height);
|
||||
packWriteDouble(stream, &definition->turbulence);
|
||||
|
||||
packWriteDouble(stream, &definition->foam_coverage);
|
||||
materialSave(stream, &definition->foam_material);
|
||||
|
||||
noiseSaveGenerator(stream, definition->_waves_noise);
|
||||
}
|
||||
|
@ -43,6 +46,9 @@ void waterLoad(PackStream* stream, WaterDefinition* definition)
|
|||
packReadDouble(stream, &definition->detail_height);
|
||||
packReadDouble(stream, &definition->turbulence);
|
||||
|
||||
packReadDouble(stream, &definition->foam_coverage);
|
||||
materialLoad(stream, &definition->foam_material);
|
||||
|
||||
noiseLoadGenerator(stream, definition->_waves_noise);
|
||||
|
||||
waterValidateDefinition(definition);
|
||||
|
@ -85,6 +91,12 @@ void waterAutoPreset(WaterDefinition* definition, WaterPreset preset)
|
|||
definition->waves_height = 1.0;
|
||||
definition->detail_height = 0.05;
|
||||
definition->turbulence = 0.3;
|
||||
definition->foam_coverage = 0.4;
|
||||
definition->foam_material.base.r = 0.8;
|
||||
definition->foam_material.base.g = 0.8;
|
||||
definition->foam_material.base.b = 0.8;
|
||||
definition->foam_material.reflection = 0.2;
|
||||
definition->foam_material.shininess = 1.5;
|
||||
}
|
||||
|
||||
waterValidateDefinition(definition);
|
||||
|
@ -126,11 +138,6 @@ static inline Vector3 _getNormal(WaterDefinition* definition, Vector3 base, doub
|
|||
Vector3 back, right;
|
||||
double x, z;
|
||||
|
||||
if (detail < 0.00001)
|
||||
{
|
||||
detail = 0.00001;
|
||||
}
|
||||
|
||||
x = base.x;
|
||||
z = base.z;
|
||||
|
||||
|
@ -186,6 +193,9 @@ HeightInfo waterGetHeightInfo(WaterDefinition* definition)
|
|||
Color waterLightFilter(WaterDefinition* definition, Renderer* renderer, Color light, Vector3 location, Vector3 light_location, Vector3 direction_to_light)
|
||||
{
|
||||
double factor;
|
||||
|
||||
UNUSED(renderer);
|
||||
UNUSED(light_location);
|
||||
|
||||
if (location.y < definition->height)
|
||||
{
|
||||
|
@ -215,6 +225,67 @@ Color waterLightFilter(WaterDefinition* definition, Renderer* renderer, Color li
|
|||
}
|
||||
}
|
||||
|
||||
static inline void _applyFoam(WaterDefinition* definition, Vector3 location, Vector3 normal, double detail, SurfaceMaterial* material)
|
||||
{
|
||||
Color result = definition->foam_material.base;
|
||||
double foam_factor, normal_diff, location_offset;
|
||||
|
||||
location_offset = 2.0 * detail;
|
||||
|
||||
foam_factor = 0.0;
|
||||
location.x += location_offset;
|
||||
normal_diff = 1.0 - v3Dot(normal, _getNormal(definition, location, detail));
|
||||
if (normal_diff > foam_factor)
|
||||
{
|
||||
foam_factor = normal_diff;
|
||||
}
|
||||
location.x -= location_offset * 2.0;
|
||||
normal_diff = 1.0 - v3Dot(normal, _getNormal(definition, location, detail));
|
||||
if (normal_diff > foam_factor)
|
||||
{
|
||||
foam_factor = normal_diff;
|
||||
}
|
||||
location.x += location_offset;
|
||||
location.z -= location_offset;
|
||||
normal_diff = 1.0 - v3Dot(normal, _getNormal(definition, location, detail));
|
||||
if (normal_diff > foam_factor)
|
||||
{
|
||||
foam_factor = normal_diff;
|
||||
}
|
||||
location.z += location_offset * 2.0;
|
||||
normal_diff = 1.0 - v3Dot(normal, _getNormal(definition, location, detail));
|
||||
if (normal_diff > foam_factor)
|
||||
{
|
||||
foam_factor = normal_diff;
|
||||
}
|
||||
|
||||
foam_factor *= 10.0;
|
||||
if (foam_factor > 1.0)
|
||||
{
|
||||
foam_factor = 1.0;
|
||||
}
|
||||
|
||||
if (foam_factor <= 1.0 - definition->foam_coverage)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foam_factor = (foam_factor - (1.0 - definition->foam_coverage)) * definition->foam_coverage;
|
||||
|
||||
material->reflection = foam_factor * definition->foam_material.reflection + (1.0 - foam_factor) * material->reflection;
|
||||
material->shininess = foam_factor * definition->foam_material.shininess + (1.0 - foam_factor) * material->shininess;
|
||||
|
||||
/* TODO This should be configurable */
|
||||
if (foam_factor > 0.2)
|
||||
{
|
||||
result.a = 0.8;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.a = 0.8 * (foam_factor / 0.2);
|
||||
}
|
||||
colorMask(&material->base, &result);
|
||||
}
|
||||
|
||||
WaterResult waterGetColorDetail(WaterDefinition* definition, Renderer* renderer, Vector3 location, Vector3 look)
|
||||
{
|
||||
WaterResult result;
|
||||
|
@ -225,7 +296,11 @@ WaterResult waterGetColorDetail(WaterDefinition* definition, Renderer* renderer,
|
|||
SurfaceMaterial material;
|
||||
double detail, depth;
|
||||
|
||||
detail = renderer->getPrecision(renderer, location);
|
||||
detail = renderer->getPrecision(renderer, location) * 0.1;
|
||||
if (detail < 0.00001)
|
||||
{
|
||||
detail = 0.00001;
|
||||
}
|
||||
|
||||
location.y = _getHeight(definition, location.x, location.z);
|
||||
result.location = location;
|
||||
|
@ -252,14 +327,17 @@ WaterResult waterGetColorDetail(WaterDefinition* definition, Renderer* renderer,
|
|||
color.g = definition->material.base.g * (1.0 - definition->transparency) + result.reflected.g * definition->reflection + result.refracted.g * definition->transparency;
|
||||
color.b = definition->material.base.b * (1.0 - definition->transparency) + result.reflected.b * definition->reflection + result.refracted.b * definition->transparency;
|
||||
color.a = 1.0;
|
||||
|
||||
|
||||
material = definition->material;
|
||||
material.base = color;
|
||||
|
||||
_applyFoam(definition, location, normal, detail, &material);
|
||||
|
||||
renderer->getLightStatus(renderer, &light, location);
|
||||
color = renderer->applyLightStatus(renderer, &light, location, normal, material);
|
||||
color = renderer->applyAtmosphere(renderer, location, color);
|
||||
color = renderer->applyClouds(renderer, color, renderer->camera_location, location);
|
||||
|
||||
|
||||
result.base = definition->material.base;
|
||||
result.final = color;
|
||||
|
||||
|
|
|
@ -31,6 +31,9 @@ typedef struct
|
|||
double waves_height;
|
||||
double detail_height;
|
||||
|
||||
double foam_coverage;
|
||||
SurfaceMaterial foam_material;
|
||||
|
||||
NoiseGenerator* _waves_noise;
|
||||
} WaterDefinition;
|
||||
|
||||
|
@ -40,6 +43,7 @@ typedef struct
|
|||
Color base;
|
||||
Color reflected;
|
||||
Color refracted;
|
||||
Color foam;
|
||||
Color final;
|
||||
} WaterResult;
|
||||
|
||||
|
|
Loading…
Reference in a new issue