paysages : Small changes.

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@488 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2012-12-24 15:15:40 +00:00 committed by ThunderK
parent 67eadf9048
commit eaf72f810c
17 changed files with 123 additions and 111 deletions

View file

@ -131,7 +131,7 @@ int main(int argc, char** argv)
for (outputcount = 0; outputcount < conf_nb_pictures; outputcount++)
{
autoSetDaytimeFraction(conf_daytime_start);
/*autoSetDaytimeFraction(conf_daytime_start);*/ /* TODO */
sprintf(outputpath, "output/pic%05d.png", outputcount);
startRender(&renderer, outputpath, conf_render_params);

View file

@ -222,7 +222,7 @@ bool DialogNoise::getNoise(QWidget* parent, NoiseGenerator* noise)
return (result != 0) ? true : false;
}
void DialogNoise::closeEvent(QCloseEvent* e)
void DialogNoise::closeEvent(QCloseEvent*)
{
reject();
}

View file

@ -13,7 +13,7 @@ ExplorerChunkSky::ExplorerChunkSky(Renderer* renderer, double size, SkyboxOrient
maintain();
}
void ExplorerChunkSky::onRenderEvent(QGLWidget* widget)
void ExplorerChunkSky::onRenderEvent(QGLWidget*)
{
double size = _box_size;
Vector3 camera = renderer()->camera_location;
@ -85,7 +85,7 @@ void ExplorerChunkSky::onRenderEvent(QGLWidget* widget)
glEnd();
}
double ExplorerChunkSky::getDisplayedSizeHint(CameraDefinition* camera)
double ExplorerChunkSky::getDisplayedSizeHint(CameraDefinition*)
{
return 1000.0;
}

View file

@ -94,7 +94,7 @@ void ExplorerChunkTerrain::onCameraEvent(CameraDefinition* camera)
_lock_data.unlock();
}
void ExplorerChunkTerrain::onRenderEvent(QGLWidget* widget)
void ExplorerChunkTerrain::onRenderEvent(QGLWidget*)
{
_lock_data.lock();
int tessellation_size = _tessellation_current_size;

View file

@ -77,7 +77,8 @@ FormAtmosphere::FormAtmosphere(QWidget *parent):
addPreview(previewEast, QString(tr("East preview")));
addInputEnum(tr("Color model"), (int*)&_definition->model, QStringList(tr("Preetham/Shirley analytic model")) << tr("Bruneton/Neyret precomputed model"));
addInputDouble(tr("Day time"), &_definition->daytime, 0.14, 0.86, 0.002, 0.1);
addInputInt(tr("Day time (hour)"), &_definition->hour, 0, 23, 1, 10);
addInputInt(tr("Day time (minute)"), &_definition->minute, 0, 59, 1, 10);
addInputColor(tr("Sun color"), &_definition->sun_color);
addInputDouble(tr("Sun radius"), &_definition->sun_radius, 0.0, 0.4, 0.004, 0.04);
addInputDouble(tr("Sun halo radius"), &_definition->sun_halo_size, 0.0, 0.4, 0.004, 0.04);

View file

@ -47,7 +47,7 @@ protected:
{
cloudsLayerCopyDefinition(_original_layer, _preview_layer);
}
static Color _applyLightStatus(Renderer* renderer, LightStatus* status, Vector3 location, Vector3 normal, SurfaceMaterial material)
static Color _applyLightStatus(Renderer*, LightStatus*, Vector3, Vector3, SurfaceMaterial)
{
return COLOR_WHITE;
}

View file

@ -56,7 +56,7 @@ int main(int argc, char** argv)
app.installTranslator(&qtTranslator);
}
splash->showMessage(app.tr("Preloading..."), Qt::AlignCenter, Qt::white);
//splash->showMessage(app.tr("Preloading..."), Qt::AlignCenter, Qt::white);
app.processEvents();
paysagesInit();
@ -184,7 +184,6 @@ void MainWindow::fileNew()
if (QMessageBox::question(this, tr("Paysages 3D - New scenery"), tr("Do you want to start a new scenery ? Any unsaved changes will be lost."), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes)
{
autoGenRealisticLandscape(0);
autoSetDaytime(8, 30);
refreshAll();
}
}

View file

@ -0,0 +1,41 @@
#include "private.h"
#include <assert.h>
#include <math.h>
#include "../renderer.h"
Color basicApplyAerialPerspective(Renderer* renderer, Vector3 location, Color base)
{
Vector3 direction = v3Sub(location, renderer->camera_location);
double distance = v3Norm(direction);
AtmosphereDefinition* definition = renderer->atmosphere->definition;
double near = 10.0 - definition->humidity * 10.0;
double far = 100.0 - definition->humidity * 90.0;
double max = 0.85 + definition->humidity * 0.12;
assert(near < far);
if (distance < near)
{
return base;
}
else
{
if (distance > far)
{
distance = far;
}
double factor = (distance - near) / (far - near);
/* TODO Get sky color without celestial objects (sun, stars...) */
double angle = (1.0 - factor) * (1.0 - factor) * (1.0 - factor) * (1.0 - factor) * M_PI_4;
direction = v3Normalize(direction);
direction.y = sin(angle);
Color sky = renderer->atmosphere->getSkyColor(renderer, v3Normalize(direction));
sky.a = max * factor;
colorMask(&base, &sky);
return base;
}
}

View file

@ -25,7 +25,7 @@ static const double exposure = 0.4;
static const double ISun = 100.0;
static const double AVERAGE_GROUND_REFLECTANCE = 0.1;
#if 0
#if 1
#define RES_MU 128
#define RES_MU_S 32
#define RES_R 32

View file

@ -23,7 +23,24 @@ static int _inited = 0;
/******************** Definition ********************/
static void _validateDefinition(AtmosphereDefinition* definition)
{
UNUSED(definition);
if (definition->hour < 0)
{
definition->hour = 0;
}
if (definition->hour > 23)
{
definition->hour = 23;
}
if (definition->minute < 0)
{
definition->minute = 0;
}
if (definition->minute > 59)
{
definition->minute = 59;
}
definition->_daytime = (double)definition->hour / 24.0 + (double)definition->minute / 1440.0;
}
static AtmosphereDefinition* _createDefinition()
@ -54,7 +71,8 @@ static void _deleteDefinition(AtmosphereDefinition* definition)
static void _copyDefinition(AtmosphereDefinition* source, AtmosphereDefinition* destination)
{
destination->model = source->model;
destination->daytime = source->daytime;
destination->hour = source->hour;
destination->minute = source->minute;
destination->sun_color = source->sun_color;
destination->sun_radius = source->sun_radius;
destination->sun_halo_size = source->sun_halo_size;
@ -69,7 +87,8 @@ static void _copyDefinition(AtmosphereDefinition* source, AtmosphereDefinition*
static void _saveDefinition(PackStream* stream, AtmosphereDefinition* definition)
{
packWriteInt(stream, (int*)&definition->model);
packWriteDouble(stream, &definition->daytime);
packWriteInt(stream, &definition->hour);
packWriteInt(stream, &definition->minute);
colorSave(stream, &definition->sun_color);
packWriteDouble(stream, &definition->sun_radius);
packWriteDouble(stream, &definition->sun_halo_size);
@ -81,7 +100,8 @@ static void _saveDefinition(PackStream* stream, AtmosphereDefinition* definition
static void _loadDefinition(PackStream* stream, AtmosphereDefinition* definition)
{
packReadInt(stream, (int*)&definition->model);
packReadDouble(stream, &definition->daytime);
packReadInt(stream, &definition->hour);
packReadInt(stream, &definition->minute);
colorLoad(stream, &definition->sun_color);
packReadDouble(stream, &definition->sun_radius);
packReadDouble(stream, &definition->sun_halo_size);
@ -175,7 +195,7 @@ static Color _getSkyColor(Renderer* renderer, Vector3 direction)
static Vector3 _getSunDirection(Renderer* renderer)
{
Vector3 result;
double sun_angle = (renderer->atmosphere->definition->daytime + 0.75) * M_PI * 2.0;
double sun_angle = (renderer->atmosphere->definition->_daytime + 0.75) * M_PI * 2.0;
result.x = cos(sun_angle);
result.y = sin(sun_angle);
result.z = 0.0;
@ -207,7 +227,7 @@ static int _getSkydomeLights(Renderer* renderer, LightDefinition* lights, int ma
{
definition = renderer->atmosphere->definition;
sun_angle = (definition->daytime + 0.75) * M_PI * 2.0;
sun_angle = (definition->_daytime + 0.75) * M_PI * 2.0;
sun_direction.x = cos(sun_angle);
sun_direction.y = sin(sun_angle);
sun_direction.z = 0.0;
@ -321,14 +341,11 @@ static void _bindRenderer(AtmosphereRenderer* renderer, AtmosphereDefinition* de
switch (definition->model)
{
case ATMOSPHERE_MODEL_PREETHAM:
renderer->applyAerialPerspective = preethamApplyAerialPerspective;
break;
case ATMOSPHERE_MODEL_BRUNETON:
renderer->applyAerialPerspective = brunetonApplyAerialPerspective;
break;
default:
renderer->applyAerialPerspective = _fakeApplyAerialPerspective;
renderer->applyAerialPerspective = basicApplyAerialPerspective;
}
mutexAcquire(cache->lock);

View file

@ -135,33 +135,3 @@ Color preethamGetSkyColor(AtmosphereDefinition* definition, Vector3 eye, Vector3
colorMask(&result, &humidity_color);
return result;
}
Color preethamApplyAerialPerspective(Renderer* renderer, Vector3 location, Color base)
{
Vector3 ray = v3Sub(location, renderer->camera_location);
Vector3 direction = v3Normalize(ray);
double distance = v3Norm(ray);
AtmosphereDefinition* definition = renderer->atmosphere->definition;
double near = 10.0 - definition->humidity * 10.0;
double far = 100.0 - definition->humidity * 90.0;
double max = 0.85 + definition->humidity * 0.12;
assert(near < far);
if (distance < near)
{
return base;
}
else
{
Vector3 sun_position = renderer->atmosphere->getSunDirection(renderer);
Color sky = preethamGetSkyColor(definition, renderer->camera_location, direction, sun_position);
if (distance > far)
{
distance = far;
}
sky.a = max * ((distance - near) / (far - near));
colorMask(&base, &sky);
return base;
}
}

View file

@ -22,30 +22,35 @@ void atmosphereAutoPreset(AtmosphereDefinition* definition, AtmospherePreset pre
{
case ATMOSPHERE_PRESET_CLEAR_DAY:
definition->model = ATMOSPHERE_MODEL_BRUNETON;
definition->daytime = 0.4;
definition->hour = 15;
definition->minute = 0;
definition->dome_lighting = 0.6;
break;
case ATMOSPHERE_PRESET_CLEAR_SUNSET:
definition->model = ATMOSPHERE_MODEL_BRUNETON;
definition->daytime = 0.74;
definition->hour = 17;
definition->minute = 45;
definition->dome_lighting = 0.8;
definition->sun_radius = 0.03;
break;
case ATMOSPHERE_PRESET_HAZY_MORNING:
definition->model = ATMOSPHERE_MODEL_PREETHAM;
definition->daytime = 0.3;
definition->hour = 8;
definition->minute = 30;
definition->dome_lighting = 0.5;
definition->humidity = 0.3;
break;
case ATMOSPHERE_PRESET_FOGGY:
definition->model = ATMOSPHERE_MODEL_PREETHAM;
definition->daytime = 0.4;
definition->hour = 15;
definition->minute = 0;
definition->dome_lighting = 0.7;
definition->humidity = 0.6;
break;
case ATMOSPHERE_PRESET_STORMY:
definition->model = ATMOSPHERE_MODEL_PREETHAM;
definition->daytime = 0.4;
definition->hour = 15;
definition->minute = 0;
definition->dome_lighting = 0.3;
definition->humidity = 0.9;
break;

View file

@ -5,11 +5,12 @@
#define SPHERE_SIZE 1000.0
Color basicApplyAerialPerspective(Renderer* renderer, Vector3 location, Color base);
void brunetonInit();
Color brunetonGetSkyColor(AtmosphereDefinition* definition, Vector3 eye, Vector3 direction, Vector3 sun_position);
Color brunetonApplyAerialPerspective(Renderer* renderer, Vector3 location, Color base);
Color preethamGetSkyColor(AtmosphereDefinition* definition, Vector3 eye, Vector3 direction, Vector3 sun_position);
Color preethamApplyAerialPerspective(Renderer* renderer, Vector3 location, Color base);
#endif

View file

@ -29,13 +29,16 @@ typedef enum
typedef struct
{
AtmosphereModel model;
double daytime;
int hour;
int minute;
double humidity;
Color sun_color;
double sun_radius;
double sun_halo_size;
Curve* sun_halo_profile;
double dome_lighting;
double _daytime;
} AtmosphereDefinition;
typedef int (*FuncAtmosphereGetSkydomeLights)(Renderer* renderer, LightDefinition* array, int max_lights);

View file

@ -16,28 +16,6 @@
#include "water.h"
#include "zone.h"
void autoSetDaytime(int hour, int minute)
{
autoSetDaytimeFraction((double)hour / 24.0 + (double)minute / 1440.0);
}
void autoSetDaytimeFraction(double daytime)
{
AtmosphereDefinition* atmosphere;
daytime = fmod(daytime, 1.0);
if (daytime < 0.0)
{
daytime += 1.0;
}
atmosphere = AtmosphereDefinitionClass.create();
sceneryGetAtmosphere(atmosphere);
atmosphere->daytime = daytime;
scenerySetAtmosphere(atmosphere);
AtmosphereDefinitionClass.destroy(atmosphere);
}
void autoGenRealisticLandscape(int seed)
{
WaterDefinition water;

View file

@ -7,8 +7,6 @@
extern "C" {
#endif
void autoSetDaytime(int hour, int minute);
void autoSetDaytimeFraction(double daytime);
void autoGenRealisticLandscape(int seed);
#ifdef __cplusplus

View file

@ -32,7 +32,6 @@ void paysagesInit()
cameraDeleteDefinition(&camera);
autoGenRealisticLandscape(0);
autoSetDaytime(8, 30);
// DEBUG
/*double last_height, height, x;