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:
parent
864496475a
commit
6ff990bf8f
19 changed files with 153 additions and 126 deletions
|
@ -18,6 +18,7 @@ public:
|
|||
{
|
||||
_renderer = rendererCreate();
|
||||
_renderer.render_quality = 3;
|
||||
_renderer.applyLightStatus = _applyLightStatus;
|
||||
|
||||
_preview_layer = cloudsLayerCreateDefinition();
|
||||
|
||||
|
@ -46,6 +47,10 @@ protected:
|
|||
{
|
||||
cloudsLayerCopyDefinition(&_layer, &_preview_layer);
|
||||
}
|
||||
static Color _applyLightStatus(Renderer* renderer, LightStatus* status, Vector3 location, Vector3 normal, SurfaceMaterial material)
|
||||
{
|
||||
return COLOR_WHITE;
|
||||
}
|
||||
|
||||
private:
|
||||
Renderer _renderer;
|
||||
|
@ -76,8 +81,8 @@ public:
|
|||
|
||||
_renderer = rendererCreate();
|
||||
_renderer.render_quality = 3;
|
||||
_renderer.applyLightingToSurface = _applyLightingToSurface;
|
||||
_renderer.maskLight = _maskLight;
|
||||
_renderer.alterLight = _alterLight;
|
||||
_renderer.getLightStatus = _getLightStatus;
|
||||
_renderer.customData[0] = &_preview_layer;
|
||||
_renderer.customData[1] = &_lighting;
|
||||
|
||||
|
@ -128,13 +133,15 @@ private:
|
|||
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);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ public:
|
|||
_renderer = rendererCreate();
|
||||
_renderer.applyTextures = _applyTextures;
|
||||
_renderer.getTerrainHeight = _getTerrainHeight;
|
||||
_renderer.applyLightingToSurface = _applyLightingToSurface;
|
||||
_renderer.maskLight = _maskLight;
|
||||
_renderer.alterLight = _alterLight;
|
||||
_renderer.getLightStatus = _getLightStatus;
|
||||
_renderer.camera_location.x = 0.0;
|
||||
_renderer.camera_location.y = 50.0;
|
||||
_renderer.camera_location.z = 0.0;
|
||||
|
@ -79,14 +79,14 @@ private:
|
|||
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);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -50,8 +50,8 @@ public:
|
|||
_renderer.render_quality = 3;
|
||||
_renderer.applyTextures = _applyTextures;
|
||||
_renderer.getTerrainHeight = _getTerrainHeight;
|
||||
_renderer.applyLightingToSurface = _applyLightingToSurface;
|
||||
_renderer.maskLight = _maskLight;
|
||||
_renderer.alterLight = _alterLight;
|
||||
_renderer.getLightStatus = _getLightStatus;
|
||||
_renderer.camera_location.x = 0.0;
|
||||
_renderer.camera_location.y = 50.0;
|
||||
_renderer.camera_location.z = 0.0;
|
||||
|
@ -125,15 +125,16 @@ private:
|
|||
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 ****************/
|
||||
|
|
|
@ -89,7 +89,7 @@ public:
|
|||
|
||||
_renderer = rendererCreate();
|
||||
_renderer.render_quality = 3;
|
||||
_renderer.applyLightingToSurface = _applyLightingToSurface;
|
||||
_renderer.getLightStatus = _getLightStatus;
|
||||
_renderer.customData[0] = &_lighting;
|
||||
_renderer.camera_location.x = 0.0;
|
||||
_renderer.camera_location.y = 20.0;
|
||||
|
@ -115,15 +115,15 @@ protected:
|
|||
zoneCopy(_zone, _preview_layer.zone);
|
||||
}
|
||||
private:
|
||||
static Color _applyLightingToSurface(Renderer* renderer, Vector3 location, Vector3 normal, SurfaceMaterial material)
|
||||
{
|
||||
return lightingApplyToSurface((LightingDefinition*)renderer->customData[0], renderer, location, normal, material);
|
||||
}
|
||||
|
||||
Zone* _zone;
|
||||
Renderer _renderer;
|
||||
TextureLayerDefinition _preview_layer;
|
||||
LightingDefinition _lighting;
|
||||
|
||||
static void _getLightStatus(Renderer* renderer, LightStatus* status, Vector3 location)
|
||||
{
|
||||
lightingGetStatus((LightingDefinition*)renderer->customData[0], renderer, location, status);
|
||||
}
|
||||
};
|
||||
|
||||
/**************** Form ****************/
|
||||
|
|
|
@ -76,7 +76,7 @@ public:
|
|||
|
||||
_renderer = rendererCreate();
|
||||
_renderer.rayWalking = _rayWalking;
|
||||
_renderer.applyLightingToSurface = _applyLightingToSurface;
|
||||
_renderer.getLightStatus = _getLightStatus;
|
||||
_renderer.customData[0] = &_water;
|
||||
_renderer.customData[1] = &_lighting;
|
||||
|
||||
|
@ -140,7 +140,7 @@ private:
|
|||
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 (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;
|
||||
}
|
||||
|
@ -155,16 +155,10 @@ private:
|
|||
|
||||
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)
|
||||
{
|
||||
return lightingApplyToSurface((LightingDefinition*)renderer->customData[1], renderer, location, normal, material);
|
||||
}
|
||||
else
|
||||
{
|
||||
return material.base;
|
||||
}
|
||||
lightingGetStatus((LightingDefinition*)renderer->customData[1], renderer, location, status);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -177,7 +171,7 @@ FormWater::FormWater(QWidget *parent):
|
|||
previewCoverage = new PreviewWaterCoverage(this);
|
||||
previewColor = new PreviewWaterColor(this);
|
||||
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);
|
||||
addInputMaterial(tr("Surface material"), &_definition.material);
|
||||
|
|
|
@ -12,6 +12,7 @@ InputBoolean::InputBoolean(QWidget* form, QString label, int* value) : BaseInput
|
|||
connect(checkbox, SIGNAL(stateChanged(int)), this, SLOT(applyValue()));
|
||||
|
||||
_preview = new QLabel(form);
|
||||
((QLabel*)_preview)->setAlignment(Qt::AlignCenter);
|
||||
_control = checkbox;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ InputDouble::InputDouble(QWidget* form, QString label, double* value, double min
|
|||
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(applyValue()));
|
||||
|
||||
_preview = new QLabel(form);
|
||||
((QLabel*)_preview)->setAlignment(Qt::AlignCenter);
|
||||
_control = slider;
|
||||
}
|
||||
|
||||
|
|
|
@ -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()));
|
||||
|
||||
_preview = new QLabel(form);
|
||||
((QLabel*)_preview)->setAlignment(Qt::AlignCenter);
|
||||
_control = slider;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
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):
|
||||
|
@ -93,8 +93,8 @@ WidgetWanderer::WidgetWanderer(QWidget *parent, CameraDefinition* camera):
|
|||
_renderer.customData[3] = &_water;
|
||||
_renderer.applyTextures = _applyTextures;
|
||||
_renderer.getTerrainHeight = _getTerrainHeight;
|
||||
_renderer.applyLightingToSurface = _applyLightingToSurface;
|
||||
_renderer.maskLight = _maskLight;
|
||||
_renderer.alterLight = _alterLight;
|
||||
_renderer.getLightStatus = _getLightStatus;
|
||||
|
||||
_updated = false;
|
||||
|
||||
|
|
|
@ -307,12 +307,12 @@ Maintenir Ctrl : Plus rapide</translation>
|
|||
<context>
|
||||
<name>FormClouds</name>
|
||||
<message>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="148"/>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="155"/>
|
||||
<source>Layer coverage (no lighting)</source>
|
||||
<translation>Couverture de la couche (sans éclairage)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="149"/>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="156"/>
|
||||
<source>Color and lighting</source>
|
||||
<translation>Echantillon éclairé</translation>
|
||||
</message>
|
||||
|
@ -329,37 +329,37 @@ Maintenir Ctrl : Plus rapide</translation>
|
|||
<translation type="obsolete">Altitude de fin</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="151"/>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="158"/>
|
||||
<source>Lower altitude</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="152"/>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="159"/>
|
||||
<source>Upper altitude</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="153"/>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="160"/>
|
||||
<source>Density by altitude</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="154"/>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="161"/>
|
||||
<source>Noise</source>
|
||||
<translation>Bruit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="155"/>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="162"/>
|
||||
<source>Coverage</source>
|
||||
<translation>Couverture</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="156"/>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="163"/>
|
||||
<source>Scaling</source>
|
||||
<translation>Echelle</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="157"/>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="164"/>
|
||||
<source>Material</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -376,22 +376,22 @@ Maintenir Ctrl : Plus rapide</translation>
|
|||
<translation type="obsolete">Concentration de la réflexion de lumière</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="158"/>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="165"/>
|
||||
<source>Hardness to light</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="159"/>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="166"/>
|
||||
<source>Transparency depth</source>
|
||||
<translation>Distance de transparence</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="160"/>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="167"/>
|
||||
<source>Light traversal depth</source>
|
||||
<translation>Distance de traversée de la lumière</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="161"/>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="168"/>
|
||||
<source>Minimum lighting</source>
|
||||
<translation>Eclairage minimal</translation>
|
||||
</message>
|
||||
|
@ -568,7 +568,7 @@ Maintenir Ctrl : Plus rapide</translation>
|
|||
<context>
|
||||
<name>FormTerrain</name>
|
||||
<message>
|
||||
<location filename="../gui_qt/formterrain.cpp" line="147"/>
|
||||
<location filename="../gui_qt/formterrain.cpp" line="148"/>
|
||||
<source>Height preview (normalized)</source>
|
||||
<translation>Aperçu de la hauteur (normalisée)</translation>
|
||||
</message>
|
||||
|
@ -577,22 +577,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="148"/>
|
||||
<location filename="../gui_qt/formterrain.cpp" line="149"/>
|
||||
<source>Lighted preview (no texture)</source>
|
||||
<translation>Aperçu éclairé (sans texture)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formterrain.cpp" line="150"/>
|
||||
<location filename="../gui_qt/formterrain.cpp" line="151"/>
|
||||
<source>Noise</source>
|
||||
<translation>Bruit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formterrain.cpp" line="151"/>
|
||||
<location filename="../gui_qt/formterrain.cpp" line="152"/>
|
||||
<source>Height</source>
|
||||
<translation>Hauteur</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formterrain.cpp" line="152"/>
|
||||
<location filename="../gui_qt/formterrain.cpp" line="153"/>
|
||||
<source>Scaling</source>
|
||||
<translation>Echelle</translation>
|
||||
</message>
|
||||
|
@ -689,17 +689,16 @@ Maintenir Ctrl : Plus rapide</translation>
|
|||
<context>
|
||||
<name>FormWater</name>
|
||||
<message>
|
||||
<location filename="../gui_qt/formwater.cpp" line="179"/>
|
||||
<location filename="../gui_qt/formwater.cpp" line="173"/>
|
||||
<source>Coverage preview</source>
|
||||
<translation>Aperçu de la couverture</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formwater.cpp" line="180"/>
|
||||
<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>
|
||||
<location filename="../gui_qt/formwater.cpp" line="182"/>
|
||||
<location filename="../gui_qt/formwater.cpp" line="176"/>
|
||||
<source>Height</source>
|
||||
<translation>Hauteur</translation>
|
||||
</message>
|
||||
|
@ -716,47 +715,52 @@ Maintenir Ctrl : Plus rapide</translation>
|
|||
<translation type="obsolete">Concentration de la lumière réfléchie</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formwater.cpp" line="183"/>
|
||||
<location filename="../gui_qt/formwater.cpp" line="177"/>
|
||||
<source>Surface material</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formwater.cpp" line="185"/>
|
||||
<location filename="../gui_qt/formwater.cpp" line="179"/>
|
||||
<source>Transparency</source>
|
||||
<translation>Transparence</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formwater.cpp" line="186"/>
|
||||
<location filename="../gui_qt/formwater.cpp" line="180"/>
|
||||
<source>Reflection</source>
|
||||
<translation>Reflets</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formwater.cpp" line="187"/>
|
||||
<location filename="../gui_qt/formwater.cpp" line="181"/>
|
||||
<source>Transparency distance</source>
|
||||
<translation>Distance maximale de transparence</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formwater.cpp" line="184"/>
|
||||
<location filename="../gui_qt/formwater.cpp" line="178"/>
|
||||
<source>Depth color</source>
|
||||
<translation>Couleur en profondeur</translation>
|
||||
</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>
|
||||
<translation>Distance de filtrage de la lumière</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formwater.cpp" line="189"/>
|
||||
<location filename="../gui_qt/formwater.cpp" line="183"/>
|
||||
<source>Waves noise</source>
|
||||
<translation>Bruit des vagues</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formwater.cpp" line="190"/>
|
||||
<location filename="../gui_qt/formwater.cpp" line="184"/>
|
||||
<source>Waves height</source>
|
||||
<translation>Hauteur des vagues</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formwater.cpp" line="191"/>
|
||||
<location filename="../gui_qt/formwater.cpp" line="185"/>
|
||||
<source>Waves scaling</source>
|
||||
<translation>Echelle des vagues</translation>
|
||||
</message>
|
||||
|
@ -764,12 +768,12 @@ Maintenir Ctrl : Plus rapide</translation>
|
|||
<context>
|
||||
<name>InputBoolean</name>
|
||||
<message>
|
||||
<location filename="../gui_qt/inputboolean.cpp" line="22"/>
|
||||
<location filename="../gui_qt/inputboolean.cpp" line="23"/>
|
||||
<source>Yes</source>
|
||||
<translation>Oui</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/inputboolean.cpp" line="26"/>
|
||||
<location filename="../gui_qt/inputboolean.cpp" line="27"/>
|
||||
<source>No</source>
|
||||
<translation>Non</translation>
|
||||
</message>
|
||||
|
|
|
@ -153,9 +153,9 @@ CloudsLayerDefinition cloudsLayerCreateDefinition()
|
|||
result.material.base.a = 1.0;
|
||||
result.material.reflection = 0.3;
|
||||
result.material.shininess = 0.8;
|
||||
result.hardness = 0.15;
|
||||
result.hardness = 0.25;
|
||||
result.transparencydepth = 1.5;
|
||||
result.lighttraversal = 3.0;
|
||||
result.lighttraversal = 7.0;
|
||||
result.minimumlight = 0.4;
|
||||
result.scaling = 3.5;
|
||||
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)
|
||||
{
|
||||
Vector3 normal;
|
||||
Color col1, col2;
|
||||
LightStatus light;
|
||||
|
||||
normal = _getNormal(definition, position, 3.0);
|
||||
if (renderer->render_quality > 5)
|
||||
|
@ -500,7 +502,16 @@ static Color _applyLayerLighting(CloudsLayerDefinition* definition, Renderer* re
|
|||
}
|
||||
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)
|
||||
|
|
|
@ -149,25 +149,16 @@ void lightingDeleteLight(LightingDefinition* definition, int light)
|
|||
}
|
||||
|
||||
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->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;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -11,7 +11,7 @@ extern "C" {
|
|||
|
||||
#define LIGHTING_MAX_LIGHTS 10
|
||||
|
||||
typedef struct
|
||||
struct LightDefinition
|
||||
{
|
||||
Vector3 direction; /* Global direction 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 masked; /* Should the light be masked (cast shadows..) */
|
||||
double amplitude; /* Angle amplitude of the light source (for multi-sampling, pi / 2.0 for skydome) */
|
||||
} LightDefinition;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -30,11 +30,11 @@ typedef struct
|
|||
LightDefinition _autolights[LIGHTING_MAX_LIGHTS];
|
||||
} LightingDefinition;
|
||||
|
||||
typedef struct
|
||||
struct LightStatus
|
||||
{
|
||||
int nblights;
|
||||
LightDefinition lights[LIGHTING_MAX_LIGHTS * 2];
|
||||
} LightStatus;
|
||||
};
|
||||
|
||||
void lightingInit();
|
||||
void lightingQuit();
|
||||
|
|
|
@ -54,19 +54,18 @@ static void _pushQuad(Renderer* renderer, Vertex* v1, Vertex* v2, Vertex* v3, Ve
|
|||
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)
|
||||
|
@ -128,9 +127,9 @@ Renderer rendererCreate()
|
|||
result.applyAtmosphere = _applyAtmosphere;
|
||||
result.applyClouds = _applyClouds;
|
||||
|
||||
result.filterLight = _filterLight;
|
||||
result.maskLight = _maskLight;
|
||||
result.applyLightingToSurface = _applyLightingToSurface;
|
||||
result.alterLight = _alterLight;
|
||||
result.getLightStatus = _getLightStatus;
|
||||
result.applyLightStatus = _applyLightStatus;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -39,9 +39,9 @@ struct Renderer
|
|||
Color (*applyClouds)(Renderer* renderer, Color base, Vector3 start, Vector3 end);
|
||||
|
||||
/* Lighting related */
|
||||
Color (*filterLight)(Renderer* renderer, Color light_color, Vector3 at_location, Vector3 light_location, Vector3 direction_to_light);
|
||||
Color (*maskLight)(Renderer* renderer, Color light_color, Vector3 at_location, Vector3 light_location, Vector3 direction_to_light);
|
||||
Color (*applyLightingToSurface)(Renderer* renderer, Vector3 location, Vector3 normal, SurfaceMaterial material);
|
||||
void (*alterLight)(Renderer* renderer, LightDefinition* light, Vector3 location);
|
||||
void (*getLightStatus)(Renderer* renderer, LightStatus* status, Vector3 location);
|
||||
Color (*applyLightStatus)(Renderer* renderer, LightStatus* status, Vector3 location, Vector3 normal, SurfaceMaterial material);
|
||||
|
||||
/* Custom data */
|
||||
void* customData[10];
|
||||
|
|
|
@ -236,25 +236,34 @@ void sceneryRenderFirstPass(Renderer* 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
|
||||
light_color = waterLightFilter(&_water, renderer, light_color, at_location, light_location, direction_to_light);
|
||||
|
||||
return light_color;
|
||||
light->color = waterLightFilter(&_water, renderer, light->color, location, light_location, direction_to_light);
|
||||
}
|
||||
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);
|
||||
light_color = cloudsFilterLight(&_clouds, renderer, light_color, at_location, light_location, direction_to_light);
|
||||
|
||||
return light_color;
|
||||
lightingGetStatus(&_lighting, renderer, location, status);
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -333,9 +342,9 @@ Renderer sceneryCreateStandardRenderer()
|
|||
cameraCopyDefinition(&_camera, &result.render_camera);
|
||||
result.camera_location = _camera.location;
|
||||
|
||||
result.filterLight = _filterLight;
|
||||
result.maskLight = _maskLight;
|
||||
result.applyLightingToSurface = _applyLightingToSurface;
|
||||
result.alterLight = _alterLight;
|
||||
result.getLightStatus = _getLightStatus;
|
||||
result.applyLightStatus = _applyLightStatus;
|
||||
result.rayWalking = _rayWalking;
|
||||
result.getTerrainHeight = _getTerrainHeight;
|
||||
result.getWaterHeightInfo = _getWaterHeightInfo;
|
||||
|
|
|
@ -11,6 +11,9 @@ extern "C" {
|
|||
struct RenderFragment;
|
||||
struct Renderer;
|
||||
|
||||
typedef struct LightDefinition LightDefinition;
|
||||
typedef struct LightStatus LightStatus;
|
||||
|
||||
typedef int(*f_RenderFragmentCallback)(struct RenderFragment*, struct Renderer* renderer, void* data);
|
||||
|
||||
typedef struct
|
||||
|
|
|
@ -338,7 +338,10 @@ double texturesGetLayerCoverage(TextureLayerDefinition* definition, Renderer* re
|
|||
|
||||
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)
|
||||
|
|
|
@ -187,6 +187,7 @@ WaterResult waterGetColorDetail(WaterDefinition* definition, Renderer* renderer,
|
|||
RayCastingResult refracted;
|
||||
Vector3 normal;
|
||||
Color color;
|
||||
LightStatus light;
|
||||
SurfaceMaterial material;
|
||||
double detail, depth;
|
||||
|
||||
|
@ -220,7 +221,8 @@ WaterResult waterGetColorDetail(WaterDefinition* definition, Renderer* renderer,
|
|||
|
||||
material = definition->material;
|
||||
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->applyClouds(renderer, color, renderer->camera_location, location);
|
||||
|
||||
|
|
Loading…
Reference in a new issue