paysages : Small changes and optimizations.

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@327 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2012-05-11 13:34:45 +00:00 committed by ThunderK
parent fe3c08a522
commit c46f52a97e
5 changed files with 40 additions and 29 deletions

7
TODO
View file

@ -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.

View file

@ -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)

View file

@ -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;

View file

@ -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,17 +198,21 @@ 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++)
{
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));
}
}
}
_lock_data.lock();
delete _texture;

View file

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