diff --git a/ChangeLog b/ChangeLog
index 6e0fed1..8f6dc08 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,7 @@
* Version management in saved files.
* Added ground texture and sun location in 3D explorer.
* 3D explorer now takes advantage of multiple CPU cores.
+* Added sun halo control.
2012-04-20 Technology Preview 1
-------------------------------
diff --git a/gui_qt/formsky.cpp b/gui_qt/formsky.cpp
index 91b335b..5526c05 100644
--- a/gui_qt/formsky.cpp
+++ b/gui_qt/formsky.cpp
@@ -90,7 +90,9 @@ FormSky::FormSky(QWidget *parent):
addInputDouble(tr("Day time"), &_definition.daytime, 0.0, 1.0, 0.01, 0.1);
addInputColorGradation(tr("Sun color"), _definition.sun_color);
- addInputDouble(tr("Sun radius"), &_definition.sun_radius, 0.0, 0.3, 0.01, 0.03);
+ 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);
+ addInputCurve(tr("Sun halo profile"), _definition.sun_halo_profile, 0.0, 1.0, 0.0, 1.0);
addInputColorGradation(tr("Zenith color"), _definition.zenith_color);
addInputColorGradation(tr("Haze color"), _definition.haze_color);
addInputDouble(tr("Haze height"), &_definition.haze_height, 0.0, 1.0, 0.01, 0.1);
diff --git a/i18n/paysages_fr.ts b/i18n/paysages_fr.ts
index 35ac8d3..1856135 100644
--- a/i18n/paysages_fr.ts
+++ b/i18n/paysages_fr.ts
@@ -546,21 +546,31 @@ Maintenir Ctrl : Plus rapide
+
+
+
+
+
+
+
+
+
+
Couleur du ciel au zénith
-
+
Couleur de la brume
-
+
Hauteur apparente de la brume
-
+
Facteur de lissage de la brume
diff --git a/lib_paysages/auto.c b/lib_paysages/auto.c
index 763f0f3..7e07973 100644
--- a/lib_paysages/auto.c
+++ b/lib_paysages/auto.c
@@ -127,6 +127,11 @@ void autoGenRealisticLandscape(int seed)
sky.haze_height = 0.75;
sky.haze_smoothing = 0.3;
sky.sun_radius = 0.02;
+ sky.sun_halo_size = 0.3;
+ curveClear(sky.sun_halo_profile);
+ curveQuickAddPoint(sky.sun_halo_profile, 0.0, 1.0);
+ curveQuickAddPoint(sky.sun_halo_profile, 0.1, 0.2);
+ curveQuickAddPoint(sky.sun_halo_profile, 1.0, 0.0);
scenerySetSky(&sky);
skyDeleteDefinition(&sky);
diff --git a/lib_paysages/sky.c b/lib_paysages/sky.c
index bfcc259..954d75e 100644
--- a/lib_paysages/sky.c
+++ b/lib_paysages/sky.c
@@ -26,6 +26,8 @@ void skySave(PackStream* stream, SkyDefinition* definition)
packWriteDouble(stream, &definition->daytime);
colorGradationSave(stream, definition->sun_color);
packWriteDouble(stream, &definition->sun_radius);
+ packWriteDouble(stream, &definition->sun_halo_size);
+ curveSave(stream, definition->sun_halo_profile);
colorGradationSave(stream, definition->zenith_color);
colorGradationSave(stream, definition->haze_color);
packWriteDouble(stream, &definition->haze_height);
@@ -37,6 +39,8 @@ void skyLoad(PackStream* stream, SkyDefinition* definition)
packReadDouble(stream, &definition->daytime);
colorGradationLoad(stream, definition->sun_color);
packReadDouble(stream, &definition->sun_radius);
+ packReadDouble(stream, &definition->sun_halo_size);
+ curveLoad(stream, definition->sun_halo_profile);
colorGradationLoad(stream, definition->zenith_color);
colorGradationLoad(stream, definition->haze_color);
packReadDouble(stream, &definition->haze_height);
@@ -52,6 +56,8 @@ SkyDefinition skyCreateDefinition()
def.daytime = 0.0;
def.sun_color = colorGradationCreate();
def.sun_radius = 1.0;
+ def.sun_halo_size = 0.0;
+ def.sun_halo_profile = curveCreate();
def.zenith_color = colorGradationCreate();
def.haze_color = colorGradationCreate();
def.haze_height = 0.0;
@@ -64,6 +70,7 @@ SkyDefinition skyCreateDefinition()
void skyDeleteDefinition(SkyDefinition* definition)
{
+ curveDelete(definition->sun_halo_profile);
colorGradationDelete(definition->sun_color);
colorGradationDelete(definition->zenith_color);
colorGradationDelete(definition->haze_color);
@@ -73,9 +80,12 @@ void skyCopyDefinition(SkyDefinition* source, SkyDefinition* destination)
{
destination->daytime = source->daytime;
destination->sun_radius = source->sun_radius;
+ destination->sun_halo_size = source->sun_halo_size;
destination->haze_height = source->haze_height;
destination->haze_smoothing = source->haze_smoothing;
+ curveCopy(source->sun_halo_profile, destination->sun_halo_profile);
+
colorGradationCopy(source->sun_color, destination->sun_color);
colorGradationCopy(source->zenith_color, destination->zenith_color);
colorGradationCopy(source->haze_color, destination->haze_color);
@@ -152,17 +162,17 @@ Color skyGetColor(SkyDefinition* definition, Renderer* renderer, Vector3 eye, Ve
dist = v3Norm(v3Sub(look, sun_position));
sky_color = colorGradationGet(definition->_sky_gradation, look.y * 0.5 + 0.5);
- if (dist < definition->sun_radius)
+ if (dist < definition->sun_radius + definition->sun_halo_size)
{
- dist = dist / definition->sun_radius;
sun_color = colorGradationGet(definition->sun_color, definition->daytime);
- if (dist < 0.9)
+ if (dist <= definition->sun_radius)
{
return sun_color;
}
else
{
- sun_color.a = (1.0 - dist) / 0.1;
+ dist = (dist - definition->sun_radius) / definition->sun_halo_size;
+ sun_color.a = curveGetValue(definition->sun_halo_profile, dist);
colorMask(&sky_color, &sun_color);
return sky_color;
}
diff --git a/lib_paysages/sky.h b/lib_paysages/sky.h
index e966a79..764e74b 100644
--- a/lib_paysages/sky.h
+++ b/lib_paysages/sky.h
@@ -15,6 +15,8 @@ typedef struct
double daytime;
ColorGradation* sun_color;
double sun_radius;
+ double sun_halo_size;
+ Curve* sun_halo_profile;
ColorGradation* zenith_color;
ColorGradation* haze_color;
double haze_height;