From c46f52a97ec383817eba3920193c2f5d4bfea43d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Fri, 11 May 2012 13:34:45 +0000 Subject: [PATCH] paysages : Small changes and optimizations. git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@327 b1fd45b6-86a6-48da-8261-f70d1f35bdcc --- TODO | 7 +++++-- gui_qt/formclouds.cpp | 22 +++++++++++----------- gui_qt/formterrain.cpp | 8 +++++--- gui_qt/wandererchunk.cpp | 22 ++++++++++++++-------- i18n/paysages_fr.ts | 10 +++++----- 5 files changed, 40 insertions(+), 29 deletions(-) diff --git a/TODO b/TODO index b8ce9bf..4abfe0e 100644 --- a/TODO +++ b/TODO @@ -11,19 +11,22 @@ Technology Preview 2 : - Add a material editor dialog. - Add a zone editor dialog for localized textures. - Add a terrain modifier dialog with zones. +- Use the curve editor in noise editor - Add a noise filler (and maybe noise intervals ?). - Fix the distorted sun appearance. - Improve curve editor. => Add curve modes => Improve curve rendering - => Add axis labels + => Add axis labels and grid + => Add logarithmic mode - Improve 3d explorer - => Restore LOD and intelligent poly count + => Restore LOD and intelligent poly count (and raise max tessellation) => Interrupt chunk rendering when quitting dialog => Don't display the water if it's below all ground => Try to overcome the near frustum cutting => Disable texture reflection of light (dependant on camera location) => Add toggles (for water...) + => Max texture size should depend on GPU memory available - Water and terrain LOD moves with the camera, fix it like in the wanderer. - Pause previews drawing of main window when a dialog is opened. - Interrupt preview chunk renderings that will be discarded at commit, or that are no more visible. diff --git a/gui_qt/formclouds.cpp b/gui_qt/formclouds.cpp index 568742f..3426f73 100644 --- a/gui_qt/formclouds.cpp +++ b/gui_qt/formclouds.cpp @@ -82,7 +82,7 @@ public: _renderer.customData[0] = &_preview_layer; _renderer.customData[1] = &_lighting; - configScaling(100.0, 400.0, 20.0, 200.0); + configScaling(1.0, 4.0, 0.2, 2.0); } protected: QColor getColor(double x, double y) @@ -90,13 +90,13 @@ protected: Vector3 start, end; Color color_layer, result; - start.x = x; - start.y = -y; - start.z = 100.0; + start.x = x * _preview_layer.ymax; + start.y = -y * _preview_layer.ymax; + start.z = _preview_layer.ymax; - end.x = x; - end.y = -y; - end.z = -100.0; + end.x = x * _preview_layer.ymax; + end.y = -y * _preview_layer.ymax; + end.z = -_preview_layer.ymax; result = COLOR_BLUE; color_layer = cloudsGetLayerColor(&_preview_layer, &_renderer, start, end); @@ -106,9 +106,9 @@ protected: void updateData() { cloudsLayerCopyDefinition(&_layer, &_preview_layer); - _preview_layer.ymin = -100.0; + _preview_layer.ymax = (_preview_layer.ymax - _preview_layer.ymin) / 2.0; _preview_layer.ycenter = 0.0; - _preview_layer.ymax = 100.0; + _preview_layer.ymin = -_preview_layer.ymin; _preview_layer.customcoverage = _coverageFunc; } private: @@ -120,13 +120,13 @@ private: { double dist = v3Norm(position); - if (dist >= 100.0) + if (dist >= layer->ymax) { return 0.0; } else { - return 1.0 - dist / 100.0; + return 1.0 - dist / layer->ymax; } } static Color _applyLightingToSurface(Renderer* renderer, Vector3 location, Vector3 normal, SurfaceMaterial material) diff --git a/gui_qt/formterrain.cpp b/gui_qt/formterrain.cpp index e910f95..0a5486e 100644 --- a/gui_qt/formterrain.cpp +++ b/gui_qt/formterrain.cpp @@ -7,6 +7,7 @@ #include "../lib_paysages/terrain.h" #include "../lib_paysages/scenery.h" +#include "../lib_paysages/euclid.h" #include "../lib_paysages/shared/constants.h" static TerrainDefinition _definition; @@ -60,9 +61,10 @@ public: light.color.g = 0.6; light.color.b = 0.6; light.amplitude = 0.0; - light.direction.x = -0.5; - light.direction.y = -0.7071; - light.direction.z = 0.5; + light.direction.x = -1.0; + light.direction.y = -0.5; + light.direction.z = 1.0; + light.direction = v3Normalize(light.direction); light.filtered = 0; light.masked = 1; light.reflection = 1.0; diff --git a/gui_qt/wandererchunk.cpp b/gui_qt/wandererchunk.cpp index a7fb68c..70da920 100644 --- a/gui_qt/wandererchunk.cpp +++ b/gui_qt/wandererchunk.cpp @@ -55,7 +55,9 @@ void WandererChunk::render(QGLWidget* widget) { widget->deleteTexture(_texture_id); } - _texture_id = widget->bindTexture(*_texture); + // TODO Only do the scale if not power-of-two textures are unsupported by GPU + _texture_id = widget->bindTexture(_texture->scaled(_texture_current_size, _texture_current_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + //_texture_id = widget->bindTexture(*_texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); } @@ -196,15 +198,19 @@ bool WandererChunk::maintain() if (_texture_current_size < _texture_max_size) { int new_texture_size = _texture_current_size ? _texture_current_size * 2 : 1; - double step_size = _texture_current_size ? _size / (double)(new_texture_size - 1) : 0.1; - QImage* new_image = new QImage(new_texture_size, new_texture_size, QImage::Format_ARGB32); - for (int j = 0; j < new_texture_size; j++) + double step_size = _texture_current_size ? _size / (double)(new_texture_size) : 0.1; + //QImage* new_image = new QImage(new_texture_size, new_texture_size, QImage::Format_ARGB32); + QImage* new_image = new QImage(_texture->scaled(new_texture_size + 1, new_texture_size + 1, Qt::IgnoreAspectRatio, Qt::FastTransformation)); + for (int j = 0; j <= new_texture_size; j++) { - for (int i = 0; i < new_texture_size; i++) + for (int i = 0; i <= new_texture_size; i++) { - Vector3 location = {_startx + step_size * (double)i, 0.0, _startz + step_size * (double)j}; - Color color = _renderer->applyTextures(_renderer, location, step_size); - new_image->setPixel(i, j, colorTo32BitRGBA(&color)); + if (_texture_current_size <= 1 || i % 2 != 0 || j % 2 != 0) + { + Vector3 location = {_startx + step_size * (double)i, 0.0, _startz + step_size * (double)j}; + Color color = _renderer->applyTextures(_renderer, location, step_size); + new_image->setPixel(i, j, colorTo32BitRGBA(&color)); + } } } diff --git a/i18n/paysages_fr.ts b/i18n/paysages_fr.ts index d6bd209..d621f74 100644 --- a/i18n/paysages_fr.ts +++ b/i18n/paysages_fr.ts @@ -477,7 +477,7 @@ Maintenir Ctrl : Plus rapide FormTerrain - + Height preview (normalized) Aperçu de la hauteur (normalisée) @@ -486,22 +486,22 @@ Maintenir Ctrl : Plus rapide Aperçu du rendu (sans ombres) - + Lighted preview (no texture) Aperçu éclairé (sans texture) - + Noise Bruit - + Height Hauteur - + Scaling Echelle