paysages : Changed lighting dispatching system (through Renderer) for future improvements.

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@336 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2012-06-05 20:22:12 +00:00 committed by ThunderK
parent 864496475a
commit 6ff990bf8f
19 changed files with 153 additions and 126 deletions

View file

@ -18,6 +18,7 @@ public:
{ {
_renderer = rendererCreate(); _renderer = rendererCreate();
_renderer.render_quality = 3; _renderer.render_quality = 3;
_renderer.applyLightStatus = _applyLightStatus;
_preview_layer = cloudsLayerCreateDefinition(); _preview_layer = cloudsLayerCreateDefinition();
@ -46,6 +47,10 @@ protected:
{ {
cloudsLayerCopyDefinition(&_layer, &_preview_layer); cloudsLayerCopyDefinition(&_layer, &_preview_layer);
} }
static Color _applyLightStatus(Renderer* renderer, LightStatus* status, Vector3 location, Vector3 normal, SurfaceMaterial material)
{
return COLOR_WHITE;
}
private: private:
Renderer _renderer; Renderer _renderer;
@ -76,8 +81,8 @@ public:
_renderer = rendererCreate(); _renderer = rendererCreate();
_renderer.render_quality = 3; _renderer.render_quality = 3;
_renderer.applyLightingToSurface = _applyLightingToSurface; _renderer.alterLight = _alterLight;
_renderer.maskLight = _maskLight; _renderer.getLightStatus = _getLightStatus;
_renderer.customData[0] = &_preview_layer; _renderer.customData[0] = &_preview_layer;
_renderer.customData[1] = &_lighting; _renderer.customData[1] = &_lighting;
@ -128,13 +133,15 @@ private:
return 1.0 - dist / layer->ymax; return 1.0 - dist / layer->ymax;
} }
} }
static Color _applyLightingToSurface(Renderer* renderer, Vector3 location, Vector3 normal, SurfaceMaterial material)
static void _alterLight(Renderer* renderer, LightDefinition* light, Vector3 location)
{ {
return lightingApplyToSurface((LightingDefinition*)renderer->customData[1], renderer, location, normal, material); light->color = cloudsLayerFilterLight((CloudsLayerDefinition*)renderer->customData[0], renderer, light->color, location, v3Scale(light->direction, -1000.0), v3Scale(light->direction, -1.0));
} }
static Color _maskLight(Renderer* renderer, Color light_color, Vector3 at_location, Vector3 light_location, Vector3 direction_to_light)
static void _getLightStatus(Renderer* renderer, LightStatus* status, Vector3 location)
{ {
return cloudsLayerFilterLight((CloudsLayerDefinition*)renderer->customData[0], renderer, light_color, at_location, light_location, direction_to_light); lightingGetStatus((LightingDefinition*)renderer->customData[1], renderer, location, status);
} }
}; };

View file

@ -17,8 +17,8 @@ public:
_renderer = rendererCreate(); _renderer = rendererCreate();
_renderer.applyTextures = _applyTextures; _renderer.applyTextures = _applyTextures;
_renderer.getTerrainHeight = _getTerrainHeight; _renderer.getTerrainHeight = _getTerrainHeight;
_renderer.applyLightingToSurface = _applyLightingToSurface; _renderer.alterLight = _alterLight;
_renderer.maskLight = _maskLight; _renderer.getLightStatus = _getLightStatus;
_renderer.camera_location.x = 0.0; _renderer.camera_location.x = 0.0;
_renderer.camera_location.y = 50.0; _renderer.camera_location.y = 50.0;
_renderer.camera_location.z = 0.0; _renderer.camera_location.z = 0.0;
@ -79,14 +79,14 @@ private:
return texturesGetColor((TexturesDefinition*)(renderer->customData[1]), renderer, location.x, location.z, precision); return texturesGetColor((TexturesDefinition*)(renderer->customData[1]), renderer, location.x, location.z, precision);
} }
static Color _applyLightingToSurface(Renderer* renderer, Vector3 location, Vector3 normal, SurfaceMaterial material) static void _alterLight(Renderer* renderer, LightDefinition* light, Vector3 location)
{ {
return lightingApplyToSurface((LightingDefinition*)renderer->customData[2], renderer, location, normal, material); light->color = terrainLightFilter((TerrainDefinition*)(renderer->customData[0]), renderer, light->color, location, v3Scale(light->direction, -1000.0), v3Scale(light->direction, -1.0));
} }
static Color _maskLight(Renderer* renderer, Color light_color, Vector3 at_location, Vector3 light_location, Vector3 direction_to_light) static void _getLightStatus(Renderer* renderer, LightStatus* status, Vector3 location)
{ {
return terrainLightFilter((TerrainDefinition*)(renderer->customData[0]), renderer, light_color, at_location, light_location, direction_to_light); lightingGetStatus((LightingDefinition*)renderer->customData[2], renderer, location, status);
} }
}; };

View file

@ -50,8 +50,8 @@ public:
_renderer.render_quality = 3; _renderer.render_quality = 3;
_renderer.applyTextures = _applyTextures; _renderer.applyTextures = _applyTextures;
_renderer.getTerrainHeight = _getTerrainHeight; _renderer.getTerrainHeight = _getTerrainHeight;
_renderer.applyLightingToSurface = _applyLightingToSurface; _renderer.alterLight = _alterLight;
_renderer.maskLight = _maskLight; _renderer.getLightStatus = _getLightStatus;
_renderer.camera_location.x = 0.0; _renderer.camera_location.x = 0.0;
_renderer.camera_location.y = 50.0; _renderer.camera_location.y = 50.0;
_renderer.camera_location.z = 0.0; _renderer.camera_location.z = 0.0;
@ -125,15 +125,16 @@ private:
return texturesGetColor((TexturesDefinition*)(renderer->customData[1]), renderer, location.x, location.z, precision); return texturesGetColor((TexturesDefinition*)(renderer->customData[1]), renderer, location.x, location.z, precision);
} }
static Color _applyLightingToSurface(Renderer* renderer, Vector3 location, Vector3 normal, SurfaceMaterial material) static void _alterLight(Renderer* renderer, LightDefinition* light, Vector3 location)
{ {
return lightingApplyToSurface((LightingDefinition*)renderer->customData[2], renderer, location, normal, material); light->color = terrainLightFilter((TerrainDefinition*)(renderer->customData[0]), renderer, light->color, location, v3Scale(light->direction, -1000.0), v3Scale(light->direction, -1.0));
} }
static Color _maskLight(Renderer* renderer, Color light_color, Vector3 at_location, Vector3 light_location, Vector3 direction_to_light) static void _getLightStatus(Renderer* renderer, LightStatus* status, Vector3 location)
{ {
return terrainLightFilter((TerrainDefinition*)(renderer->customData[0]), renderer, light_color, at_location, light_location, direction_to_light); lightingGetStatus((LightingDefinition*)renderer->customData[2], renderer, location, status);
} }
}; };
/**************** Form ****************/ /**************** Form ****************/

View file

@ -89,7 +89,7 @@ public:
_renderer = rendererCreate(); _renderer = rendererCreate();
_renderer.render_quality = 3; _renderer.render_quality = 3;
_renderer.applyLightingToSurface = _applyLightingToSurface; _renderer.getLightStatus = _getLightStatus;
_renderer.customData[0] = &_lighting; _renderer.customData[0] = &_lighting;
_renderer.camera_location.x = 0.0; _renderer.camera_location.x = 0.0;
_renderer.camera_location.y = 20.0; _renderer.camera_location.y = 20.0;
@ -115,15 +115,15 @@ protected:
zoneCopy(_zone, _preview_layer.zone); zoneCopy(_zone, _preview_layer.zone);
} }
private: private:
static Color _applyLightingToSurface(Renderer* renderer, Vector3 location, Vector3 normal, SurfaceMaterial material)
{
return lightingApplyToSurface((LightingDefinition*)renderer->customData[0], renderer, location, normal, material);
}
Zone* _zone; Zone* _zone;
Renderer _renderer; Renderer _renderer;
TextureLayerDefinition _preview_layer; TextureLayerDefinition _preview_layer;
LightingDefinition _lighting; LightingDefinition _lighting;
static void _getLightStatus(Renderer* renderer, LightStatus* status, Vector3 location)
{
lightingGetStatus((LightingDefinition*)renderer->customData[0], renderer, location, status);
}
}; };
/**************** Form ****************/ /**************** Form ****************/

View file

@ -76,7 +76,7 @@ public:
_renderer = rendererCreate(); _renderer = rendererCreate();
_renderer.rayWalking = _rayWalking; _renderer.rayWalking = _rayWalking;
_renderer.applyLightingToSurface = _applyLightingToSurface; _renderer.getLightStatus = _getLightStatus;
_renderer.customData[0] = &_water; _renderer.customData[0] = &_water;
_renderer.customData[1] = &_lighting; _renderer.customData[1] = &_lighting;
@ -140,7 +140,7 @@ private:
y = location.y + direction.y * (0.0 - location.z) / direction.z; y = location.y + direction.y * (0.0 - location.z) / direction.z;
//if (((int)ceil(x * 0.2) % 2 == 0) ^ ((int)ceil(y * 0.2 - 0.5) % 2 == 0)) //if (((int)ceil(x * 0.2) % 2 == 0) ^ ((int)ceil(y * 0.2 - 0.5) % 2 == 0))
if (y * 0.1 > sin(x - M_PI_2)) if (y * 0.1 > x * 0.03 + sin(x - M_PI_2))
{ {
result.hit_color = COLOR_WHITE; result.hit_color = COLOR_WHITE;
} }
@ -155,16 +155,10 @@ private:
return result; return result;
} }
static Color _applyLightingToSurface(Renderer* renderer, Vector3 location, Vector3 normal, SurfaceMaterial material)
static void _getLightStatus(Renderer* renderer, LightStatus* status, Vector3 location)
{ {
if (location.x >= 0.0) lightingGetStatus((LightingDefinition*)renderer->customData[1], renderer, location, status);
{
return lightingApplyToSurface((LightingDefinition*)renderer->customData[1], renderer, location, normal, material);
}
else
{
return material.base;
}
} }
}; };
@ -177,7 +171,7 @@ FormWater::FormWater(QWidget *parent):
previewCoverage = new PreviewWaterCoverage(this); previewCoverage = new PreviewWaterCoverage(this);
previewColor = new PreviewWaterColor(this); previewColor = new PreviewWaterColor(this);
addPreview(previewCoverage, QString(tr("Coverage preview"))); addPreview(previewCoverage, QString(tr("Coverage preview")));
addPreview(previewColor, QString(tr("Rendered preview (without/with lighting)"))); addPreview(previewColor, QString(tr("Rendered preview")));
addInputDouble(tr("Height"), &_definition.height, -10.0, 10.0, 0.1, 1.0); addInputDouble(tr("Height"), &_definition.height, -10.0, 10.0, 0.1, 1.0);
addInputMaterial(tr("Surface material"), &_definition.material); addInputMaterial(tr("Surface material"), &_definition.material);

View file

@ -12,6 +12,7 @@ InputBoolean::InputBoolean(QWidget* form, QString label, int* value) : BaseInput
connect(checkbox, SIGNAL(stateChanged(int)), this, SLOT(applyValue())); connect(checkbox, SIGNAL(stateChanged(int)), this, SLOT(applyValue()));
_preview = new QLabel(form); _preview = new QLabel(form);
((QLabel*)_preview)->setAlignment(Qt::AlignCenter);
_control = checkbox; _control = checkbox;
} }

View file

@ -23,6 +23,7 @@ InputDouble::InputDouble(QWidget* form, QString label, double* value, double min
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(applyValue())); connect(slider, SIGNAL(valueChanged(int)), this, SLOT(applyValue()));
_preview = new QLabel(form); _preview = new QLabel(form);
((QLabel*)_preview)->setAlignment(Qt::AlignCenter);
_control = slider; _control = slider;
} }

View file

@ -22,6 +22,7 @@ InputInt::InputInt(QWidget* form, QString label, int* value, int min, int max, i
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(applyValue())); connect(slider, SIGNAL(valueChanged(int)), this, SLOT(applyValue()));
_preview = new QLabel(form); _preview = new QLabel(form);
((QLabel*)_preview)->setAlignment(Qt::AlignCenter);
_control = slider; _control = slider;
} }

View file

@ -55,14 +55,14 @@ static Color _applyTextures(Renderer* renderer, Vector3 location, double precisi
return texturesGetColor((TexturesDefinition*)(renderer->customData[1]), renderer, location.x, location.z, precision); return texturesGetColor((TexturesDefinition*)(renderer->customData[1]), renderer, location.x, location.z, precision);
} }
static Color _applyLightingToSurface(Renderer* renderer, Vector3 location, Vector3 normal, SurfaceMaterial material) static void _alterLight(Renderer* renderer, LightDefinition* light, Vector3 location)
{ {
return lightingApplyToSurface((LightingDefinition*)renderer->customData[2], renderer, location, normal, material); light->color = terrainLightFilter((TerrainDefinition*)(renderer->customData[0]), renderer, light->color, location, v3Scale(light->direction, -1000.0), v3Scale(light->direction, -1.0));
} }
static Color _maskLight(Renderer* renderer, Color light_color, Vector3 at_location, Vector3 light_location, Vector3 direction_to_light) static void _getLightStatus(Renderer* renderer, LightStatus* status, Vector3 location)
{ {
return terrainLightFilter((TerrainDefinition*)(renderer->customData[0]), renderer, light_color, at_location, light_location, direction_to_light); lightingGetStatus((LightingDefinition*)renderer->customData[2], renderer, location, status);
} }
WidgetWanderer::WidgetWanderer(QWidget *parent, CameraDefinition* camera): WidgetWanderer::WidgetWanderer(QWidget *parent, CameraDefinition* camera):
@ -93,8 +93,8 @@ WidgetWanderer::WidgetWanderer(QWidget *parent, CameraDefinition* camera):
_renderer.customData[3] = &_water; _renderer.customData[3] = &_water;
_renderer.applyTextures = _applyTextures; _renderer.applyTextures = _applyTextures;
_renderer.getTerrainHeight = _getTerrainHeight; _renderer.getTerrainHeight = _getTerrainHeight;
_renderer.applyLightingToSurface = _applyLightingToSurface; _renderer.alterLight = _alterLight;
_renderer.maskLight = _maskLight; _renderer.getLightStatus = _getLightStatus;
_updated = false; _updated = false;

View file

@ -307,12 +307,12 @@ Maintenir Ctrl : Plus rapide</translation>
<context> <context>
<name>FormClouds</name> <name>FormClouds</name>
<message> <message>
<location filename="../gui_qt/formclouds.cpp" line="148"/> <location filename="../gui_qt/formclouds.cpp" line="155"/>
<source>Layer coverage (no lighting)</source> <source>Layer coverage (no lighting)</source>
<translation>Couverture de la couche (sans éclairage)</translation> <translation>Couverture de la couche (sans éclairage)</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formclouds.cpp" line="149"/> <location filename="../gui_qt/formclouds.cpp" line="156"/>
<source>Color and lighting</source> <source>Color and lighting</source>
<translation>Echantillon éclairé</translation> <translation>Echantillon éclairé</translation>
</message> </message>
@ -329,37 +329,37 @@ Maintenir Ctrl : Plus rapide</translation>
<translation type="obsolete">Altitude de fin</translation> <translation type="obsolete">Altitude de fin</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formclouds.cpp" line="151"/> <location filename="../gui_qt/formclouds.cpp" line="158"/>
<source>Lower altitude</source> <source>Lower altitude</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formclouds.cpp" line="152"/> <location filename="../gui_qt/formclouds.cpp" line="159"/>
<source>Upper altitude</source> <source>Upper altitude</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formclouds.cpp" line="153"/> <location filename="../gui_qt/formclouds.cpp" line="160"/>
<source>Density by altitude</source> <source>Density by altitude</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formclouds.cpp" line="154"/> <location filename="../gui_qt/formclouds.cpp" line="161"/>
<source>Noise</source> <source>Noise</source>
<translation>Bruit</translation> <translation>Bruit</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formclouds.cpp" line="155"/> <location filename="../gui_qt/formclouds.cpp" line="162"/>
<source>Coverage</source> <source>Coverage</source>
<translation>Couverture</translation> <translation>Couverture</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formclouds.cpp" line="156"/> <location filename="../gui_qt/formclouds.cpp" line="163"/>
<source>Scaling</source> <source>Scaling</source>
<translation>Echelle</translation> <translation>Echelle</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formclouds.cpp" line="157"/> <location filename="../gui_qt/formclouds.cpp" line="164"/>
<source>Material</source> <source>Material</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -376,22 +376,22 @@ Maintenir Ctrl : Plus rapide</translation>
<translation type="obsolete">Concentration de la réflexion de lumière</translation> <translation type="obsolete">Concentration de la réflexion de lumière</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formclouds.cpp" line="158"/> <location filename="../gui_qt/formclouds.cpp" line="165"/>
<source>Hardness to light</source> <source>Hardness to light</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formclouds.cpp" line="159"/> <location filename="../gui_qt/formclouds.cpp" line="166"/>
<source>Transparency depth</source> <source>Transparency depth</source>
<translation>Distance de transparence</translation> <translation>Distance de transparence</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formclouds.cpp" line="160"/> <location filename="../gui_qt/formclouds.cpp" line="167"/>
<source>Light traversal depth</source> <source>Light traversal depth</source>
<translation>Distance de traversée de la lumière</translation> <translation>Distance de traversée de la lumière</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formclouds.cpp" line="161"/> <location filename="../gui_qt/formclouds.cpp" line="168"/>
<source>Minimum lighting</source> <source>Minimum lighting</source>
<translation>Eclairage minimal</translation> <translation>Eclairage minimal</translation>
</message> </message>
@ -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="147"/> <location filename="../gui_qt/formterrain.cpp" line="148"/>
<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="148"/> <location filename="../gui_qt/formterrain.cpp" line="149"/>
<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="150"/> <location filename="../gui_qt/formterrain.cpp" line="151"/>
<source>Noise</source> <source>Noise</source>
<translation>Bruit</translation> <translation>Bruit</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formterrain.cpp" line="151"/> <location filename="../gui_qt/formterrain.cpp" line="152"/>
<source>Height</source> <source>Height</source>
<translation>Hauteur</translation> <translation>Hauteur</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formterrain.cpp" line="152"/> <location filename="../gui_qt/formterrain.cpp" line="153"/>
<source>Scaling</source> <source>Scaling</source>
<translation>Echelle</translation> <translation>Echelle</translation>
</message> </message>
@ -689,17 +689,16 @@ Maintenir Ctrl : Plus rapide</translation>
<context> <context>
<name>FormWater</name> <name>FormWater</name>
<message> <message>
<location filename="../gui_qt/formwater.cpp" line="179"/> <location filename="../gui_qt/formwater.cpp" line="173"/>
<source>Coverage preview</source> <source>Coverage preview</source>
<translation>Aperçu de la couverture</translation> <translation>Aperçu de la couverture</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formwater.cpp" line="180"/>
<source>Rendered preview (without/with lighting)</source> <source>Rendered preview (without/with lighting)</source>
<translation>Aperçu du rendu (sans/avec éclairage)</translation> <translation type="obsolete">Aperçu du rendu (sans/avec éclairage)</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formwater.cpp" line="182"/> <location filename="../gui_qt/formwater.cpp" line="176"/>
<source>Height</source> <source>Height</source>
<translation>Hauteur</translation> <translation>Hauteur</translation>
</message> </message>
@ -716,47 +715,52 @@ Maintenir Ctrl : Plus rapide</translation>
<translation type="obsolete">Concentration de la lumière réfléchie</translation> <translation type="obsolete">Concentration de la lumière réfléchie</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formwater.cpp" line="183"/> <location filename="../gui_qt/formwater.cpp" line="177"/>
<source>Surface material</source> <source>Surface material</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formwater.cpp" line="185"/> <location filename="../gui_qt/formwater.cpp" line="179"/>
<source>Transparency</source> <source>Transparency</source>
<translation>Transparence</translation> <translation>Transparence</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formwater.cpp" line="186"/> <location filename="../gui_qt/formwater.cpp" line="180"/>
<source>Reflection</source> <source>Reflection</source>
<translation>Reflets</translation> <translation>Reflets</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formwater.cpp" line="187"/> <location filename="../gui_qt/formwater.cpp" line="181"/>
<source>Transparency distance</source> <source>Transparency distance</source>
<translation>Distance maximale de transparence</translation> <translation>Distance maximale de transparence</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formwater.cpp" line="184"/> <location filename="../gui_qt/formwater.cpp" line="178"/>
<source>Depth color</source> <source>Depth color</source>
<translation>Couleur en profondeur</translation> <translation>Couleur en profondeur</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formwater.cpp" line="188"/> <location filename="../gui_qt/formwater.cpp" line="174"/>
<source>Rendered preview</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/formwater.cpp" line="182"/>
<source>Light-through distance</source> <source>Light-through distance</source>
<translation>Distance de filtrage de la lumière</translation> <translation>Distance de filtrage de la lumière</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formwater.cpp" line="189"/> <location filename="../gui_qt/formwater.cpp" line="183"/>
<source>Waves noise</source> <source>Waves noise</source>
<translation>Bruit des vagues</translation> <translation>Bruit des vagues</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formwater.cpp" line="190"/> <location filename="../gui_qt/formwater.cpp" line="184"/>
<source>Waves height</source> <source>Waves height</source>
<translation>Hauteur des vagues</translation> <translation>Hauteur des vagues</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formwater.cpp" line="191"/> <location filename="../gui_qt/formwater.cpp" line="185"/>
<source>Waves scaling</source> <source>Waves scaling</source>
<translation>Echelle des vagues</translation> <translation>Echelle des vagues</translation>
</message> </message>
@ -764,12 +768,12 @@ Maintenir Ctrl : Plus rapide</translation>
<context> <context>
<name>InputBoolean</name> <name>InputBoolean</name>
<message> <message>
<location filename="../gui_qt/inputboolean.cpp" line="22"/> <location filename="../gui_qt/inputboolean.cpp" line="23"/>
<source>Yes</source> <source>Yes</source>
<translation>Oui</translation> <translation>Oui</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/inputboolean.cpp" line="26"/> <location filename="../gui_qt/inputboolean.cpp" line="27"/>
<source>No</source> <source>No</source>
<translation>Non</translation> <translation>Non</translation>
</message> </message>

View file

@ -153,9 +153,9 @@ CloudsLayerDefinition cloudsLayerCreateDefinition()
result.material.base.a = 1.0; result.material.base.a = 1.0;
result.material.reflection = 0.3; result.material.reflection = 0.3;
result.material.shininess = 0.8; result.material.shininess = 0.8;
result.hardness = 0.15; result.hardness = 0.25;
result.transparencydepth = 1.5; result.transparencydepth = 1.5;
result.lighttraversal = 3.0; result.lighttraversal = 7.0;
result.minimumlight = 0.4; result.minimumlight = 0.4;
result.scaling = 3.5; result.scaling = 3.5;
result.coverage = 0.45; result.coverage = 0.45;
@ -487,6 +487,8 @@ static int _findSegments(CloudsLayerDefinition* definition, Renderer* renderer,
static Color _applyLayerLighting(CloudsLayerDefinition* definition, Renderer* renderer, Vector3 position, double detail) static Color _applyLayerLighting(CloudsLayerDefinition* definition, Renderer* renderer, Vector3 position, double detail)
{ {
Vector3 normal; Vector3 normal;
Color col1, col2;
LightStatus light;
normal = _getNormal(definition, position, 3.0); normal = _getNormal(definition, position, 3.0);
if (renderer->render_quality > 5) if (renderer->render_quality > 5)
@ -500,7 +502,16 @@ static Color _applyLayerLighting(CloudsLayerDefinition* definition, Renderer* re
} }
normal = v3Scale(v3Normalize(normal), definition->hardness); normal = v3Scale(v3Normalize(normal), definition->hardness);
return renderer->applyLightingToSurface(renderer, position, normal, definition->material); renderer->getLightStatus(renderer, &light, position);
col1 = renderer->applyLightStatus(renderer, &light, position, normal, definition->material);
col2 = renderer->applyLightStatus(renderer, &light, position, v3Scale(normal, -1.0), definition->material);
col1.r = (col1.r + col2.r) / 2.0;
col1.g = (col1.g + col2.g) / 2.0;
col1.b = (col1.b + col2.b) / 2.0;
col1.a = (col1.a + col2.a) / 2.0;
return col1;
} }
Color cloudsGetLayerColor(CloudsLayerDefinition* definition, Renderer* renderer, Vector3 start, Vector3 end) Color cloudsGetLayerColor(CloudsLayerDefinition* definition, Renderer* renderer, Vector3 start, Vector3 end)

View file

@ -149,25 +149,16 @@ void lightingDeleteLight(LightingDefinition* definition, int light)
} }
static int _getLightStatus(LightDefinition* definition, Renderer* renderer, Vector3 location, LightDefinition* result) static int _getLightStatus(LightDefinition* definition, Renderer* renderer, Vector3 location, LightDefinition* result)
{
Color light;
Vector3 direction_inv;
light = definition->color;
direction_inv = v3Scale(definition->direction, -1.0);
if (definition->masked)
{
light = renderer->maskLight(renderer, light, location, v3Add(location, v3Scale(direction_inv, 1000.0)), direction_inv);
}
if (definition->filtered)
{
light = renderer->filterLight(renderer, light, location, v3Add(location, v3Scale(direction_inv, 1000.0)), direction_inv);
}
if (light.r > 0.0 || light.g > 0.0 || light.b > 0.0)
{ {
*result = *definition; *result = *definition;
result->color = light;
if (definition->masked || definition->filtered)
{
renderer->alterLight(renderer, result, location);
}
if (result->color.r > 0.0 || result->color.g > 0.0 || result->color.b > 0.0)
{
return 1; return 1;
} }
else else

View file

@ -11,7 +11,7 @@ extern "C" {
#define LIGHTING_MAX_LIGHTS 10 #define LIGHTING_MAX_LIGHTS 10
typedef struct struct LightDefinition
{ {
Vector3 direction; /* Global direction of the light */ Vector3 direction; /* Global direction of the light */
Color color; /* Main color of the light */ Color color; /* Main color of the light */
@ -19,7 +19,7 @@ typedef struct
int filtered; /* Should the light be filtered (by atmosphere, water...) */ int filtered; /* Should the light be filtered (by atmosphere, water...) */
int masked; /* Should the light be masked (cast shadows..) */ int masked; /* Should the light be masked (cast shadows..) */
double amplitude; /* Angle amplitude of the light source (for multi-sampling, pi / 2.0 for skydome) */ double amplitude; /* Angle amplitude of the light source (for multi-sampling, pi / 2.0 for skydome) */
} LightDefinition; };
typedef struct typedef struct
{ {
@ -30,11 +30,11 @@ typedef struct
LightDefinition _autolights[LIGHTING_MAX_LIGHTS]; LightDefinition _autolights[LIGHTING_MAX_LIGHTS];
} LightingDefinition; } LightingDefinition;
typedef struct struct LightStatus
{ {
int nblights; int nblights;
LightDefinition lights[LIGHTING_MAX_LIGHTS * 2]; LightDefinition lights[LIGHTING_MAX_LIGHTS * 2];
} LightStatus; };
void lightingInit(); void lightingInit();
void lightingQuit(); void lightingQuit();

View file

@ -54,19 +54,18 @@ static void _pushQuad(Renderer* renderer, Vertex* v1, Vertex* v2, Vertex* v3, Ve
renderer->pushTriangle(renderer, v4, v1, v3); renderer->pushTriangle(renderer, v4, v1, v3);
} }
static Color _filterLight(Renderer* renderer, Color light_color, Vector3 at_location, Vector3 light_location, Vector3 direction_to_light) static void _alterLight(Renderer* renderer, LightDefinition* light, Vector3 location)
{ {
return light_color;
} }
static Color _maskLight(Renderer* renderer, Color light_color, Vector3 at_location, Vector3 light_location, Vector3 direction_to_light) static void _getLightStatus(Renderer* renderer, LightStatus* status, Vector3 location)
{ {
return light_color; status->nblights = 0;
} }
static Color _applyLightingToSurface(Renderer* renderer, Vector3 location, Vector3 normal, SurfaceMaterial material) static Color _applyLightStatus(Renderer* renderer, LightStatus* status, Vector3 location, Vector3 normal, SurfaceMaterial material)
{ {
return material.base; return lightingApplyStatusToSurface(renderer, status, location, normal, material);
} }
static RayCastingResult _rayWalking(Renderer* renderer, Vector3 location, Vector3 direction, int terrain, int water, int sky, int clouds) static RayCastingResult _rayWalking(Renderer* renderer, Vector3 location, Vector3 direction, int terrain, int water, int sky, int clouds)
@ -128,9 +127,9 @@ Renderer rendererCreate()
result.applyAtmosphere = _applyAtmosphere; result.applyAtmosphere = _applyAtmosphere;
result.applyClouds = _applyClouds; result.applyClouds = _applyClouds;
result.filterLight = _filterLight; result.alterLight = _alterLight;
result.maskLight = _maskLight; result.getLightStatus = _getLightStatus;
result.applyLightingToSurface = _applyLightingToSurface; result.applyLightStatus = _applyLightStatus;
return result; return result;
} }

View file

@ -39,9 +39,9 @@ struct Renderer
Color (*applyClouds)(Renderer* renderer, Color base, Vector3 start, Vector3 end); Color (*applyClouds)(Renderer* renderer, Color base, Vector3 start, Vector3 end);
/* Lighting related */ /* Lighting related */
Color (*filterLight)(Renderer* renderer, Color light_color, Vector3 at_location, Vector3 light_location, Vector3 direction_to_light); void (*alterLight)(Renderer* renderer, LightDefinition* light, Vector3 location);
Color (*maskLight)(Renderer* renderer, Color light_color, Vector3 at_location, Vector3 light_location, Vector3 direction_to_light); void (*getLightStatus)(Renderer* renderer, LightStatus* status, Vector3 location);
Color (*applyLightingToSurface)(Renderer* renderer, Vector3 location, Vector3 normal, SurfaceMaterial material); Color (*applyLightStatus)(Renderer* renderer, LightStatus* status, Vector3 location, Vector3 normal, SurfaceMaterial material);
/* Custom data */ /* Custom data */
void* customData[10]; void* customData[10];

View file

@ -236,25 +236,34 @@ void sceneryRenderFirstPass(Renderer* renderer)
/******* Standard renderer *********/ /******* Standard renderer *********/
static Color _filterLight(Renderer* renderer, Color light_color, Vector3 at_location, Vector3 light_location, Vector3 direction_to_light) static void _alterLight(Renderer* renderer, LightDefinition* light, Vector3 location)
{
Vector3 light_location;
Vector3 direction_to_light;
direction_to_light = v3Normalize(v3Scale(light->direction, -1.0));
light_location = v3Add(location, v3Scale(direction_to_light, 1000.0));
if (light->filtered)
{ {
// TODO atmosphere filter // TODO atmosphere filter
light_color = waterLightFilter(&_water, renderer, light_color, at_location, light_location, direction_to_light); light->color = waterLightFilter(&_water, renderer, light->color, location, light_location, direction_to_light);
}
return light_color; if (light->masked)
{
light->color = terrainLightFilter(&_terrain, renderer, light->color, location, light_location, direction_to_light);
light->color = cloudsFilterLight(&_clouds, renderer, light->color, location, light_location, direction_to_light);
}
} }
static Color _maskLight(Renderer* renderer, Color light_color, Vector3 at_location, Vector3 light_location, Vector3 direction_to_light) static void _getLightStatus(Renderer* renderer, LightStatus* status, Vector3 location)
{ {
light_color = terrainLightFilter(&_terrain, renderer, light_color, at_location, light_location, direction_to_light); lightingGetStatus(&_lighting, renderer, location, status);
light_color = cloudsFilterLight(&_clouds, renderer, light_color, at_location, light_location, direction_to_light);
return light_color;
} }
static Color _applyLightingToSurface(Renderer* renderer, Vector3 location, Vector3 normal, SurfaceMaterial material) static Color _applyLightStatus(Renderer* renderer, LightStatus* status, Vector3 location, Vector3 normal, SurfaceMaterial material)
{ {
return lightingApplyToSurface(&_lighting, renderer, location, normal, material); return lightingApplyStatusToSurface(renderer, status, location, normal, material);
} }
static RayCastingResult _rayWalking(Renderer* renderer, Vector3 location, Vector3 direction, int terrain, int water, int sky, int clouds) static RayCastingResult _rayWalking(Renderer* renderer, Vector3 location, Vector3 direction, int terrain, int water, int sky, int clouds)
@ -333,9 +342,9 @@ Renderer sceneryCreateStandardRenderer()
cameraCopyDefinition(&_camera, &result.render_camera); cameraCopyDefinition(&_camera, &result.render_camera);
result.camera_location = _camera.location; result.camera_location = _camera.location;
result.filterLight = _filterLight; result.alterLight = _alterLight;
result.maskLight = _maskLight; result.getLightStatus = _getLightStatus;
result.applyLightingToSurface = _applyLightingToSurface; result.applyLightStatus = _applyLightStatus;
result.rayWalking = _rayWalking; result.rayWalking = _rayWalking;
result.getTerrainHeight = _getTerrainHeight; result.getTerrainHeight = _getTerrainHeight;
result.getWaterHeightInfo = _getWaterHeightInfo; result.getWaterHeightInfo = _getWaterHeightInfo;

View file

@ -11,6 +11,9 @@ extern "C" {
struct RenderFragment; struct RenderFragment;
struct Renderer; struct Renderer;
typedef struct LightDefinition LightDefinition;
typedef struct LightStatus LightStatus;
typedef int(*f_RenderFragmentCallback)(struct RenderFragment*, struct Renderer* renderer, void* data); typedef int(*f_RenderFragmentCallback)(struct RenderFragment*, struct Renderer* renderer, void* data);
typedef struct typedef struct

View file

@ -338,7 +338,10 @@ double texturesGetLayerCoverage(TextureLayerDefinition* definition, Renderer* re
static inline Color _getLayerColor(Renderer* renderer, TextureResult result) static inline Color _getLayerColor(Renderer* renderer, TextureResult result)
{ {
return renderer->applyLightingToSurface(renderer, result.location, result.normal, result.definition->material); LightStatus light;
renderer->getLightStatus(renderer, &light, result.location);
return renderer->applyLightStatus(renderer, &light, result.location, result.normal, result.definition->material);
} }
Color texturesGetLayerColor(TextureLayerDefinition* definition, Renderer* renderer, Vector3 location, double detail) Color texturesGetLayerColor(TextureLayerDefinition* definition, Renderer* renderer, Vector3 location, double detail)

View file

@ -187,6 +187,7 @@ WaterResult waterGetColorDetail(WaterDefinition* definition, Renderer* renderer,
RayCastingResult refracted; RayCastingResult refracted;
Vector3 normal; Vector3 normal;
Color color; Color color;
LightStatus light;
SurfaceMaterial material; SurfaceMaterial material;
double detail, depth; double detail, depth;
@ -220,7 +221,8 @@ WaterResult waterGetColorDetail(WaterDefinition* definition, Renderer* renderer,
material = definition->material; material = definition->material;
material.base = color; material.base = color;
color = renderer->applyLightingToSurface(renderer, location, normal, material); renderer->getLightStatus(renderer, &light, location);
color = renderer->applyLightStatus(renderer, &light, location, normal, material);
color = renderer->applyAtmosphere(renderer, location, color); color = renderer->applyAtmosphere(renderer, location, color);
color = renderer->applyClouds(renderer, color, renderer->camera_location, location); color = renderer->applyClouds(renderer, color, renderer->camera_location, location);