paysages : Optimized terrain shadows.

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@332 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2012-06-02 10:03:48 +00:00 committed by ThunderK
parent 4daf92f3dd
commit d204a2c294
4 changed files with 28 additions and 7 deletions

2
TODO
View file

@ -1,5 +1,7 @@
Technology Preview 2 : Technology Preview 2 :
- Fix the fog impression when cloud layer overlaps with ground range. - 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). - Replace zone ranges with curves (with curve input and curve dialog).
- Interface for textures thickness, slope_range and thickness_transparency (and correct slider ranges). - Interface for textures thickness, slope_range and thickness_transparency (and correct slider ranges).
- Render tab previews should not rerender when changing render options. - Render tab previews should not rerender when changing render options.

View file

@ -47,6 +47,7 @@ public:
TextureLayerDefinition* texture; TextureLayerDefinition* texture;
_renderer = rendererCreate(); _renderer = rendererCreate();
_renderer.render_quality = 3;
_renderer.applyTextures = _applyTextures; _renderer.applyTextures = _applyTextures;
_renderer.getTerrainHeight = _getTerrainHeight; _renderer.getTerrainHeight = _getTerrainHeight;
_renderer.applyLightingToSurface = _applyLightingToSurface; _renderer.applyLightingToSurface = _applyLightingToSurface;

View file

@ -568,7 +568,7 @@ Maintenir Ctrl : Plus rapide</translation>
<context> <context>
<name>FormTerrain</name> <name>FormTerrain</name>
<message> <message>
<location filename="../gui_qt/formterrain.cpp" line="146"/> <location filename="../gui_qt/formterrain.cpp" line="147"/>
<source>Height preview (normalized)</source> <source>Height preview (normalized)</source>
<translation>Aperçu de la hauteur (normalisée)</translation> <translation>Aperçu de la hauteur (normalisée)</translation>
</message> </message>
@ -577,22 +577,22 @@ Maintenir Ctrl : Plus rapide</translation>
<translation type="obsolete">Aperçu du rendu (sans ombres)</translation> <translation type="obsolete">Aperçu du rendu (sans ombres)</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formterrain.cpp" line="147"/> <location filename="../gui_qt/formterrain.cpp" line="148"/>
<source>Lighted preview (no texture)</source> <source>Lighted preview (no texture)</source>
<translation>Aperçu éclairé (sans texture)</translation> <translation>Aperçu éclairé (sans texture)</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formterrain.cpp" line="149"/> <location filename="../gui_qt/formterrain.cpp" line="150"/>
<source>Noise</source> <source>Noise</source>
<translation>Bruit</translation> <translation>Bruit</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formterrain.cpp" line="150"/> <location filename="../gui_qt/formterrain.cpp" line="151"/>
<source>Height</source> <source>Height</source>
<translation>Hauteur</translation> <translation>Hauteur</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formterrain.cpp" line="151"/> <location filename="../gui_qt/formterrain.cpp" line="152"/>
<source>Scaling</source> <source>Scaling</source>
<translation>Echelle</translation> <translation>Echelle</translation>
</message> </message>

View file

@ -156,6 +156,23 @@ static inline double _getHeight(TerrainDefinition* definition, double x, double
return location.y; 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) static inline Vector3 _getPoint(TerrainDefinition* definition, double x, double z)
{ {
Vector3 result; Vector3 result;
@ -195,12 +212,13 @@ Color terrainLightFilter(TerrainDefinition* definition, Renderer* renderer, Colo
light_factor = 1.0; light_factor = 1.0;
length = 0.0; length = 0.0;
diff = 0.0;
do do
{ {
inc_vector = v3Scale(direction_to_light, inc_value); inc_vector = v3Scale(direction_to_light, inc_value);
length += v3Norm(inc_vector); length += v3Norm(inc_vector);
location = v3Add(location, 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; diff = location.y - height;
if (diff < 0.0) if (diff < 0.0)
{ {
@ -219,7 +237,7 @@ Color terrainLightFilter(TerrainDefinition* definition, Renderer* renderer, Colo
{ {
inc_value = diff; 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) if (light_factor <= 0.0)
{ {