From d204a2c294b6b8957a499bf610458b332a336ec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Sat, 2 Jun 2012 10:03:48 +0000 Subject: [PATCH] paysages : Optimized terrain shadows. git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@332 b1fd45b6-86a6-48da-8261-f70d1f35bdcc --- TODO | 2 ++ gui_qt/formterrain.cpp | 1 + i18n/paysages_fr.ts | 10 +++++----- lib_paysages/terrain.c | 22 ++++++++++++++++++++-- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/TODO b/TODO index 5e7ece1..13178d1 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,7 @@ Technology Preview 2 : - Fix the fog impression when cloud layer overlaps with ground range. +- Fix dialog previews not always updating at dialog open. +- Fix forms with layers apply and revert buttons (when deleting last cloud layer, can't apply it). - Replace zone ranges with curves (with curve input and curve dialog). - Interface for textures thickness, slope_range and thickness_transparency (and correct slider ranges). - Render tab previews should not rerender when changing render options. diff --git a/gui_qt/formterrain.cpp b/gui_qt/formterrain.cpp index 113f2ef..52711a4 100644 --- a/gui_qt/formterrain.cpp +++ b/gui_qt/formterrain.cpp @@ -47,6 +47,7 @@ public: TextureLayerDefinition* texture; _renderer = rendererCreate(); + _renderer.render_quality = 3; _renderer.applyTextures = _applyTextures; _renderer.getTerrainHeight = _getTerrainHeight; _renderer.applyLightingToSurface = _applyLightingToSurface; diff --git a/i18n/paysages_fr.ts b/i18n/paysages_fr.ts index 2fee872..0e00320 100644 --- a/i18n/paysages_fr.ts +++ b/i18n/paysages_fr.ts @@ -568,7 +568,7 @@ Maintenir Ctrl : Plus rapide FormTerrain - + Height preview (normalized) Aperçu de la hauteur (normalisée) @@ -577,22 +577,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 diff --git a/lib_paysages/terrain.c b/lib_paysages/terrain.c index afa7a9c..ead8744 100644 --- a/lib_paysages/terrain.c +++ b/lib_paysages/terrain.c @@ -156,6 +156,23 @@ static inline double _getHeight(TerrainDefinition* definition, double x, double return location.y; } +static inline double _getHeightDetail(TerrainDefinition* definition, double x, double z, double detail) +{ + Vector3 location; + int i; + + location.x = x; + location.y = noiseGet2DDetail(definition->height_noise, x / definition->scaling, z / definition->scaling, detail / definition->height_factor) * definition->height_factor; + location.z = z; + + for (i = 0; i < definition->height_modifiers_count; i++) + { + location = modifierApply(definition->height_modifiers[i], location); + } + + return location.y; +} + static inline Vector3 _getPoint(TerrainDefinition* definition, double x, double z) { Vector3 result; @@ -195,12 +212,13 @@ Color terrainLightFilter(TerrainDefinition* definition, Renderer* renderer, Colo light_factor = 1.0; length = 0.0; + diff = 0.0; do { inc_vector = v3Scale(direction_to_light, inc_value); length += v3Norm(inc_vector); location = v3Add(location, inc_vector); - height = _getHeight(definition, location.x, location.z); + height = _getHeightDetail(definition, location.x, location.z, diff / inc_factor); diff = location.y - height; if (diff < 0.0) { @@ -219,7 +237,7 @@ Color terrainLightFilter(TerrainDefinition* definition, Renderer* renderer, Colo { inc_value = diff; } - } while (light_factor > 0.0 && length < 50.0 && location.y <= definition->_max_height); + } while (light_factor > 0.0 && length < (10.0 * inc_factor) && location.y <= definition->_max_height); if (light_factor <= 0.0) {