paysages: Small changes
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@196 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
d61539e08d
commit
d8dfb6c1ab
4 changed files with 153 additions and 116 deletions
175
data/gui.glade
175
data/gui.glade
|
@ -679,6 +679,8 @@ A small entropy will make the noise repeat more often.</property>
|
||||||
<object class="GtkVBox" id="vbox12">
|
<object class="GtkVBox" id="vbox12">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
<property name="border_width">5</property>
|
||||||
|
<property name="spacing">5</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="label19">
|
<object class="GtkLabel" id="label19">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -716,7 +718,6 @@ A small entropy will make the noise repeat more often.</property>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">False</property>
|
<property name="fill">False</property>
|
||||||
<property name="padding">5</property>
|
|
||||||
<property name="position">0</property>
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
@ -724,18 +725,19 @@ A small entropy will make the noise repeat more often.</property>
|
||||||
<object class="GtkVBox" id="vbox7">
|
<object class="GtkVBox" id="vbox7">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
<property name="border_width">5</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="terrain_noise_edit">
|
<object class="GtkButton" id="terrain_noise_edit">
|
||||||
<property name="label" translatable="yes">Edit noise</property>
|
<property name="label" translatable="yes">Edit noise</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
|
<property name="border_width">5</property>
|
||||||
<property name="use_action_appearance">False</property>
|
<property name="use_action_appearance">False</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">False</property>
|
<property name="fill">False</property>
|
||||||
<property name="padding">5</property>
|
|
||||||
<property name="position">0</property>
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
@ -746,7 +748,6 @@ A small entropy will make the noise repeat more often.</property>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">True</property>
|
<property name="expand">True</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
<property name="padding">5</property>
|
|
||||||
<property name="position">1</property>
|
<property name="position">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
@ -853,6 +854,7 @@ A small entropy will make the noise repeat more often.</property>
|
||||||
<object class="GtkVBox" id="vbox13">
|
<object class="GtkVBox" id="vbox13">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
<property name="border_width">5</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="water_noise_edit">
|
<object class="GtkButton" id="water_noise_edit">
|
||||||
<property name="label" translatable="yes">Edit noise (waves)</property>
|
<property name="label" translatable="yes">Edit noise (waves)</property>
|
||||||
|
@ -1004,7 +1006,6 @@ A small entropy will make the noise repeat more often.</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="border_width">5</property>
|
<property name="border_width">5</property>
|
||||||
<property name="spacing">10</property>
|
|
||||||
<property name="layout_style">spread</property>
|
<property name="layout_style">spread</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="water_apply">
|
<object class="GtkButton" id="water_apply">
|
||||||
|
@ -1171,21 +1172,6 @@ A small entropy will make the noise repeat more often.</property>
|
||||||
<property name="height">1</property>
|
<property name="height">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkImage" id="sky_colorgradient_sun">
|
|
||||||
<property name="width_request">250</property>
|
|
||||||
<property name="height_request">20</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="stock">gtk-missing-image</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">1</property>
|
|
||||||
<property name="top_attach">1</property>
|
|
||||||
<property name="width">1</property>
|
|
||||||
<property name="height">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="label30">
|
<object class="GtkLabel" id="label30">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -1227,21 +1213,6 @@ A small entropy will make the noise repeat more often.</property>
|
||||||
<property name="height">1</property>
|
<property name="height">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkImage" id="sky_colorgradient_zenith">
|
|
||||||
<property name="width_request">250</property>
|
|
||||||
<property name="height_request">20</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="stock">gtk-missing-image</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">1</property>
|
|
||||||
<property name="top_attach">3</property>
|
|
||||||
<property name="width">1</property>
|
|
||||||
<property name="height">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="label33">
|
<object class="GtkLabel" id="label33">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -1255,21 +1226,6 @@ A small entropy will make the noise repeat more often.</property>
|
||||||
<property name="height">1</property>
|
<property name="height">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkImage" id="sky_colorgradient_haze">
|
|
||||||
<property name="width_request">250</property>
|
|
||||||
<property name="height_request">20</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="stock">gtk-missing-image</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">1</property>
|
|
||||||
<property name="top_attach">4</property>
|
|
||||||
<property name="width">1</property>
|
|
||||||
<property name="height">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="label34">
|
<object class="GtkLabel" id="label34">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -1326,6 +1282,126 @@ A small entropy will make the noise repeat more often.</property>
|
||||||
<property name="height">1</property>
|
<property name="height">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkHBox" id="hbox1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="sky_colorgradient_sun">
|
||||||
|
<property name="width_request">200</property>
|
||||||
|
<property name="height_request">30</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="stock">gtk-missing-image</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">True</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="sky_colorgradient_sun_edit">
|
||||||
|
<property name="label" translatable="yes">Edit</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<property name="use_action_appearance">False</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">True</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="top_attach">1</property>
|
||||||
|
<property name="width">1</property>
|
||||||
|
<property name="height">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkHBox" id="hbox6">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="sky_colorgradient_zenith">
|
||||||
|
<property name="width_request">200</property>
|
||||||
|
<property name="height_request">30</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="stock">gtk-missing-image</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">True</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="sky_colorgradient_zenith_edit">
|
||||||
|
<property name="label" translatable="yes">Edit</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<property name="use_action_appearance">False</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">True</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="top_attach">3</property>
|
||||||
|
<property name="width">1</property>
|
||||||
|
<property name="height">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkHBox" id="hbox8">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="sky_colorgradient_haze">
|
||||||
|
<property name="width_request">200</property>
|
||||||
|
<property name="height_request">30</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="stock">gtk-missing-image</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">True</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="sky_colorgradient_haze_edit">
|
||||||
|
<property name="label" translatable="yes">Edit</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<property name="use_action_appearance">False</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">True</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="top_attach">4</property>
|
||||||
|
<property name="width">1</property>
|
||||||
|
<property name="height">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
|
@ -1338,7 +1414,6 @@ A small entropy will make the noise repeat more often.</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="border_width">5</property>
|
<property name="border_width">5</property>
|
||||||
<property name="spacing">10</property>
|
|
||||||
<property name="layout_style">spread</property>
|
<property name="layout_style">spread</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="sky_apply">
|
<object class="GtkButton" id="sky_apply">
|
||||||
|
|
|
@ -185,6 +185,7 @@ void autoGenRealisticLandscape(int seed)
|
||||||
|
|
||||||
/* Sky */
|
/* Sky */
|
||||||
sky.sun_color = colorGradationCreate();
|
sky.sun_color = colorGradationCreate();
|
||||||
|
colorGradationAddRgba(&sky.sun_color, 0.5, 1.0, 0.98, 0.95, 1.0);
|
||||||
sky.zenith_color = colorGradationCreate();
|
sky.zenith_color = colorGradationCreate();
|
||||||
colorGradationAddRgba(&sky.zenith_color, 0.2, 0.03, 0.03, 0.05, 1.0);
|
colorGradationAddRgba(&sky.zenith_color, 0.2, 0.03, 0.03, 0.05, 1.0);
|
||||||
colorGradationAddRgba(&sky.zenith_color, 0.25, 0.25, 0.33, 0.37, 1.0);
|
colorGradationAddRgba(&sky.zenith_color, 0.25, 0.25, 0.33, 0.37, 1.0);
|
||||||
|
|
85
src/clouds.c
85
src/clouds.c
|
@ -23,7 +23,7 @@ typedef struct
|
||||||
void cloudsInit()
|
void cloudsInit()
|
||||||
{
|
{
|
||||||
_layers_count = 0;
|
_layers_count = 0;
|
||||||
|
|
||||||
_quality.precision = 0.5;
|
_quality.precision = 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ void cloudsSave(FILE* f)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
CloudsDefinition* layer;
|
CloudsDefinition* layer;
|
||||||
|
|
||||||
toolsSaveInt(f, _layers_count);
|
toolsSaveInt(f, _layers_count);
|
||||||
for (i = 0; i < _layers_count; i++)
|
for (i = 0; i < _layers_count; i++)
|
||||||
{
|
{
|
||||||
|
@ -50,7 +50,7 @@ void cloudsLoad(FILE* f)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
CloudsDefinition* layer;
|
CloudsDefinition* layer;
|
||||||
|
|
||||||
_layers_count = toolsLoadInt(f);
|
_layers_count = toolsLoadInt(f);
|
||||||
for (i = 0; i < _layers_count; i++)
|
for (i = 0; i < _layers_count; i++)
|
||||||
{
|
{
|
||||||
|
@ -73,11 +73,11 @@ int cloudsGetLayerCount()
|
||||||
int cloudsAddLayer()
|
int cloudsAddLayer()
|
||||||
{
|
{
|
||||||
CloudsDefinition* layer;
|
CloudsDefinition* layer;
|
||||||
|
|
||||||
layer = _layers + _layers_count;
|
layer = _layers + _layers_count;
|
||||||
layer->noise = noiseCreateGenerator();
|
layer->noise = noiseCreateGenerator();
|
||||||
layer->coverage = 0.0;
|
layer->coverage = 0.0;
|
||||||
|
|
||||||
return _layers_count++;
|
return _layers_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ void cloudsDeleteLayer(int layer)
|
||||||
CloudsDefinition cloudsCreateDefinition()
|
CloudsDefinition cloudsCreateDefinition()
|
||||||
{
|
{
|
||||||
CloudsDefinition result;
|
CloudsDefinition result;
|
||||||
|
|
||||||
result.color = COLOR_WHITE;
|
result.color = COLOR_WHITE;
|
||||||
result.coverage = 0.0;
|
result.coverage = 0.0;
|
||||||
result.noise = noiseCreateGenerator();
|
result.noise = noiseCreateGenerator();
|
||||||
|
@ -97,7 +97,7 @@ CloudsDefinition cloudsCreateDefinition()
|
||||||
result.ymin = 0.0;
|
result.ymin = 0.0;
|
||||||
result.ycenter = 0.0;
|
result.ycenter = 0.0;
|
||||||
result.ymax = 0.0;
|
result.ymax = 0.0;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ void cloudsDeleteDefinition(CloudsDefinition definition)
|
||||||
void cloudsCopyDefinition(CloudsDefinition source, CloudsDefinition* destination)
|
void cloudsCopyDefinition(CloudsDefinition source, CloudsDefinition* destination)
|
||||||
{
|
{
|
||||||
NoiseGenerator* noise;
|
NoiseGenerator* noise;
|
||||||
|
|
||||||
noise = destination->noise;
|
noise = destination->noise;
|
||||||
*destination = source;
|
*destination = source;
|
||||||
destination->noise = noise;
|
destination->noise = noise;
|
||||||
|
@ -119,7 +119,7 @@ void cloudsCopyDefinition(CloudsDefinition source, CloudsDefinition* destination
|
||||||
void cloudsSetDefinition(int layer, CloudsDefinition definition)
|
void cloudsSetDefinition(int layer, CloudsDefinition definition)
|
||||||
{
|
{
|
||||||
CloudsDefinition* destination;
|
CloudsDefinition* destination;
|
||||||
|
|
||||||
if (layer >= 0 && layer < _layers_count)
|
if (layer >= 0 && layer < _layers_count)
|
||||||
{
|
{
|
||||||
destination = _layers + layer;
|
destination = _layers + layer;
|
||||||
|
@ -150,45 +150,6 @@ CloudsQuality cloudsGetQuality()
|
||||||
return _quality;
|
return _quality;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*int cloudsAddLayer(double ymin, double ycenter, double ymax, Color color, double scaling, double coverage)
|
|
||||||
{
|
|
||||||
CloudsDefinition* layer = _layers + _layers_count;
|
|
||||||
|
|
||||||
layer->ycenter = ycenter;
|
|
||||||
layer->ymin = ymin;
|
|
||||||
layer->ymax = ymax;
|
|
||||||
layer->color = color;
|
|
||||||
layer->scaling = scaling;
|
|
||||||
layer->coverage = coverage;
|
|
||||||
|
|
||||||
layer->noise = noiseCreateGenerator();
|
|
||||||
noiseGenerateBaseNoise(layer->noise, 262144);
|
|
||||||
noiseAddLevelSimple(layer->noise, scaling, 0.3);
|
|
||||||
noiseAddLevelSimple(layer->noise, scaling / 2.0, 0.2);
|
|
||||||
noiseAddLevelSimple(layer->noise, scaling / 4.0, 0.1);
|
|
||||||
noiseAddLevelSimple(layer->noise, scaling / 10.0, 0.05);
|
|
||||||
noiseAddLevelSimple(layer->noise, scaling / 20.0, 0.03);
|
|
||||||
noiseAddLevelSimple(layer->noise, scaling / 40.0, 0.02);
|
|
||||||
noiseAddLevelSimple(layer->noise, scaling / 60.0, 0.01);
|
|
||||||
noiseAddLevelSimple(layer->noise, scaling / 80.0, 0.005);
|
|
||||||
noiseAddLevelSimple(layer->noise, scaling / 100.0, 0.02);
|
|
||||||
noiseAddLevelSimple(layer->noise, scaling / 150.0, 0.005);
|
|
||||||
noiseAddLevelSimple(layer->noise, scaling / 200.0, 0.003);
|
|
||||||
noiseAddLevelSimple(layer->noise, scaling / 400.0, 0.008);
|
|
||||||
noiseAddLevelSimple(layer->noise, scaling / 800.0, 0.001);
|
|
||||||
noiseAddLevelSimple(layer->noise, scaling / 1000.0, 0.0005);
|
|
||||||
if (coverage < 0.5)
|
|
||||||
{
|
|
||||||
noiseNormalizeHeight(layer->noise, -1.0, coverage * 2.0, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
noiseNormalizeHeight(layer->noise, -(1.0 - coverage) * 2.0, 1.0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return _layers_count++;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
static inline double _getDistanceToBorder(CloudsDefinition* layer, Vector3 position, double detail)
|
static inline double _getDistanceToBorder(CloudsDefinition* layer, Vector3 position, double detail)
|
||||||
{
|
{
|
||||||
double val, min;
|
double val, min;
|
||||||
|
@ -237,7 +198,7 @@ static inline Vector3 _getNormal(CloudsDefinition* layer, Vector3 position, doub
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optimize the search limits in a layer.
|
* Optimize the search limits in a layer.
|
||||||
*
|
*
|
||||||
* @param layer The cloud layer
|
* @param layer The cloud layer
|
||||||
* @param start Start of the search to optimize
|
* @param start Start of the search to optimize
|
||||||
* @param end End of the search to optimize
|
* @param end End of the search to optimize
|
||||||
|
@ -246,7 +207,7 @@ static inline Vector3 _getNormal(CloudsDefinition* layer, Vector3 position, doub
|
||||||
static int _optimizeSearchLimits(CloudsDefinition* layer, Vector3* start, Vector3* end)
|
static int _optimizeSearchLimits(CloudsDefinition* layer, Vector3* start, Vector3* end)
|
||||||
{
|
{
|
||||||
Vector3 diff;
|
Vector3 diff;
|
||||||
|
|
||||||
if (start->y > layer->ymax)
|
if (start->y > layer->ymax)
|
||||||
{
|
{
|
||||||
if (end->y >= layer->ymax)
|
if (end->y >= layer->ymax)
|
||||||
|
@ -291,14 +252,14 @@ static int _optimizeSearchLimits(CloudsDefinition* layer, Vector3* start, Vector
|
||||||
*end = v3Add(*start, v3Scale(diff, (layer->ymin - start->y) / diff.y));
|
*end = v3Add(*start, v3Scale(diff, (layer->ymin - start->y) / diff.y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO Limit the search length */
|
/* TODO Limit the search length */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Go through the cloud layer to find segments (parts of the lookup that are inside the cloud).
|
* Go through the cloud layer to find segments (parts of the lookup that are inside the cloud).
|
||||||
*
|
*
|
||||||
* @param definition The cloud layer
|
* @param definition The cloud layer
|
||||||
* @param quality Render quality
|
* @param quality Render quality
|
||||||
* @param start Start position of the lookup (already optimized)
|
* @param start Start position of the lookup (already optimized)
|
||||||
|
@ -319,7 +280,7 @@ static int _findSegments(CloudsDefinition* definition, CloudsQuality* quality, V
|
||||||
double step_length, segment_length, remaining_length;
|
double step_length, segment_length, remaining_length;
|
||||||
double noise_distance, last_noise_distance;
|
double noise_distance, last_noise_distance;
|
||||||
Vector3 walker, step, segment_start;
|
Vector3 walker, step, segment_start;
|
||||||
|
|
||||||
if (max_segments <= 0)
|
if (max_segments <= 0)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -341,7 +302,7 @@ static int _findSegments(CloudsDefinition* definition, CloudsQuality* quality, V
|
||||||
last_noise_distance = noise_distance;
|
last_noise_distance = noise_distance;
|
||||||
noise_distance = _getDistanceToBorder(definition, walker, detail) * quality->precision;
|
noise_distance = _getDistanceToBorder(definition, walker, detail) * quality->precision;
|
||||||
current_total_length += step_length;
|
current_total_length += step_length;
|
||||||
|
|
||||||
if (noise_distance > 0.0)
|
if (noise_distance > 0.0)
|
||||||
{
|
{
|
||||||
if (inside)
|
if (inside)
|
||||||
|
@ -369,7 +330,7 @@ static int _findSegments(CloudsDefinition* definition, CloudsQuality* quality, V
|
||||||
remaining_length = step_length * last_noise_distance / (last_noise_distance - noise_distance);
|
remaining_length = step_length * last_noise_distance / (last_noise_distance - noise_distance);
|
||||||
segment_length += remaining_length;
|
segment_length += remaining_length;
|
||||||
current_inside_length += remaining_length;
|
current_inside_length += remaining_length;
|
||||||
|
|
||||||
out_segments->start = segment_start;
|
out_segments->start = segment_start;
|
||||||
out_segments->end = v3Add(walker, v3Scale(direction, remaining_length - step_length));
|
out_segments->end = v3Add(walker, v3Scale(direction, remaining_length - step_length));
|
||||||
out_segments->length = segment_length;
|
out_segments->length = segment_length;
|
||||||
|
@ -378,7 +339,7 @@ static int _findSegments(CloudsDefinition* definition, CloudsQuality* quality, V
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
inside = 0;
|
inside = 0;
|
||||||
step = v3Scale(direction, quality->precision);
|
step = v3Scale(direction, quality->precision);
|
||||||
}
|
}
|
||||||
|
@ -389,7 +350,7 @@ static int _findSegments(CloudsDefinition* definition, CloudsQuality* quality, V
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (inside || (walker.y <= definition->ymax + 0.001 && walker.y >= definition->ymin - 0.001 && current_total_length < max_total_length && current_inside_length < max_inside_length));
|
} while (inside || (walker.y <= definition->ymax + 0.001 && walker.y >= definition->ymin - 0.001 && current_total_length < max_total_length && current_inside_length < max_inside_length));
|
||||||
|
|
||||||
*total_length = current_total_length;
|
*total_length = current_total_length;
|
||||||
*inside_length = current_inside_length;
|
*inside_length = current_inside_length;
|
||||||
return segment_count;
|
return segment_count;
|
||||||
|
@ -406,7 +367,7 @@ static Color _applyLayerLighting(CloudsDefinition* definition, CloudsQuality* qu
|
||||||
normal = v3Add(normal, _getNormal(definition, position, 0.2));
|
normal = v3Add(normal, _getNormal(definition, position, 0.2));
|
||||||
normal = v3Add(normal, _getNormal(definition, position, 0.1));
|
normal = v3Add(normal, _getNormal(definition, position, 0.1));
|
||||||
result = lightingApply(position, normal, 0.0, base, 0.3, 0.1);
|
result = lightingApply(position, normal, 0.0, base, 0.3, 0.1);
|
||||||
|
|
||||||
direction = sun_direction_inv;
|
direction = sun_direction_inv;
|
||||||
detail = (detail < 0.1) ? 0.1 : detail;
|
detail = (detail < 0.1) ? 0.1 : detail;
|
||||||
/* FIXME Dont hard-code max_total_length */
|
/* FIXME Dont hard-code max_total_length */
|
||||||
|
@ -417,7 +378,7 @@ static Color _applyLayerLighting(CloudsDefinition* definition, CloudsQuality* qu
|
||||||
{
|
{
|
||||||
inside_depth = 1.0;
|
inside_depth = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.r = base.r * sun_color_lum * (0.9 - 0.2 * inside_depth) + result.r * (0.1 + 0.1 * inside_depth) + (0.1 - inside_depth * 0.1) * sun_color_lum;
|
result.r = base.r * sun_color_lum * (0.9 - 0.2 * inside_depth) + result.r * (0.1 + 0.1 * inside_depth) + (0.1 - inside_depth * 0.1) * sun_color_lum;
|
||||||
result.g = base.g * sun_color_lum * (0.9 - 0.2 * inside_depth) + result.g * (0.1 + 0.1 * inside_depth) + (0.1 - inside_depth * 0.1) * sun_color_lum;
|
result.g = base.g * sun_color_lum * (0.9 - 0.2 * inside_depth) + result.g * (0.1 + 0.1 * inside_depth) + (0.1 - inside_depth * 0.1) * sun_color_lum;
|
||||||
result.b = base.b * sun_color_lum * (0.9 - 0.2 * inside_depth) + result.b * (0.1 + 0.1 * inside_depth) + (0.1 - inside_depth * 0.1) * sun_color_lum;
|
result.b = base.b * sun_color_lum * (0.9 - 0.2 * inside_depth) + result.b * (0.1 + 0.1 * inside_depth) + (0.1 - inside_depth * 0.1) * sun_color_lum;
|
||||||
|
@ -441,12 +402,12 @@ Color cloudsGetColorCustom(Vector3 start, Vector3 end, CloudsDefinition* definit
|
||||||
{
|
{
|
||||||
environment = &_environment;
|
environment = &_environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_optimizeSearchLimits(definition, &start, &end))
|
if (!_optimizeSearchLimits(definition, &start, &end))
|
||||||
{
|
{
|
||||||
return COLOR_TRANSPARENT;
|
return COLOR_TRANSPARENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
direction = v3Sub(end, start);
|
direction = v3Sub(end, start);
|
||||||
max_length = v3Norm(direction);
|
max_length = v3Norm(direction);
|
||||||
direction = v3Normalize(direction);
|
direction = v3Normalize(direction);
|
||||||
|
@ -454,7 +415,7 @@ Color cloudsGetColorCustom(Vector3 start, Vector3 end, CloudsDefinition* definit
|
||||||
|
|
||||||
/* TODO Flexible precision */
|
/* TODO Flexible precision */
|
||||||
detail = renderGetPrecision(start) / definition->scaling;
|
detail = renderGetPrecision(start) / definition->scaling;
|
||||||
|
|
||||||
segment_count = _findSegments(definition, quality, start, direction, detail, 20, 60.0, max_length, &inside_length, &total_length, segments);
|
segment_count = _findSegments(definition, quality, start, direction, detail, 20, 60.0, max_length, &inside_length, &total_length, segments);
|
||||||
for (i = 0; i < segment_count; i++)
|
for (i = 0; i < segment_count; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,7 +29,7 @@ static inline void _updatePreview()
|
||||||
|
|
||||||
static void _redrawColorGradation(GtkImage* image, ColorGradation* gradation)
|
static void _redrawColorGradation(GtkImage* image, ColorGradation* gradation)
|
||||||
{
|
{
|
||||||
GdkPixbuf* pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, 1, 8, 250, 20);
|
GdkPixbuf* pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, 1, 8, 200, 30);
|
||||||
void* pixels = gdk_pixbuf_get_pixels(pixbuf);
|
void* pixels = gdk_pixbuf_get_pixels(pixbuf);
|
||||||
int rowstride = gdk_pixbuf_get_rowstride(pixbuf);
|
int rowstride = gdk_pixbuf_get_rowstride(pixbuf);
|
||||||
|
|
||||||
|
@ -37,12 +37,12 @@ static void _redrawColorGradation(GtkImage* image, ColorGradation* gradation)
|
||||||
guint32* pixel;
|
guint32* pixel;
|
||||||
Color col;
|
Color col;
|
||||||
|
|
||||||
for (x = 0; x < 250; x++)
|
for (x = 0; x < 200; x++)
|
||||||
{
|
{
|
||||||
for (y = 0; y < 20; y++)
|
for (y = 0; y < 30; y++)
|
||||||
{
|
{
|
||||||
pixel = (guint32*)(pixels + y * rowstride + x * 4);
|
pixel = (guint32*)(pixels + y * rowstride + x * 4);
|
||||||
col = colorGradationGet(gradation, (double)x / 250.0);
|
col = colorGradationGet(gradation, (double)x / 200.0);
|
||||||
*pixel = (guint32)colorTo32BitRGBA(&col);
|
*pixel = (guint32)colorTo32BitRGBA(&col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue