paysages: Added sun rendering.
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@197 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
d8dfb6c1ab
commit
35e9d5d0bf
6 changed files with 143 additions and 12 deletions
|
@ -15,6 +15,104 @@
|
||||||
</row>
|
</row>
|
||||||
</data>
|
</data>
|
||||||
</object>
|
</object>
|
||||||
|
<object class="GtkWindow" id="dialog_gradation">
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="title" translatable="yes">Paysages - Color gradient editor</property>
|
||||||
|
<property name="resizable">False</property>
|
||||||
|
<property name="modal">True</property>
|
||||||
|
<property name="window_position">center-on-parent</property>
|
||||||
|
<property name="destroy_with_parent">True</property>
|
||||||
|
<property name="skip_taskbar_hint">True</property>
|
||||||
|
<property name="transient_for">main_window</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox" id="box9">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkEventBox" id="eventbox7">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK</property>
|
||||||
|
<property name="border_width">5</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="gradation_editor_preview">
|
||||||
|
<property name="width_request">500</property>
|
||||||
|
<property name="height_request">50</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="stock">gtk-missing-image</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox" id="box10">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkHButtonBox" id="hbuttonbox4">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="homogeneous">True</property>
|
||||||
|
<property name="layout_style">spread</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="gradition_editor_apply">
|
||||||
|
<property name="label" translatable="yes">Validate</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">False</property>
|
||||||
|
<property name="fill">False</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="gradation_editor_cancel">
|
||||||
|
<property name="label" translatable="yes">Cancel</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">False</property>
|
||||||
|
<property name="fill">False</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">False</property>
|
||||||
|
<property name="padding">5</property>
|
||||||
|
<property name="position">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
<object class="GtkWindow" id="dialog_noise">
|
<object class="GtkWindow" id="dialog_noise">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="title" translatable="yes">Paysages - Noise editor</property>
|
<property name="title" translatable="yes">Paysages - Noise editor</property>
|
||||||
|
|
|
@ -185,7 +185,9 @@ 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);
|
colorGradationAddRgba(&sky.sun_color, 0.3, 1.0, 0.91, 0.8, 1.0);
|
||||||
|
colorGradationAddRgba(&sky.sun_color, 0.5, 1.0, 0.95, 0.9, 1.0);
|
||||||
|
colorGradationAddRgba(&sky.sun_color, 0.7, 1.0, 0.91, 0.8, 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);
|
||||||
|
@ -205,6 +207,7 @@ void autoGenRealisticLandscape(int seed)
|
||||||
sky.daytime = 0.0;
|
sky.daytime = 0.0;
|
||||||
sky.haze_height = 0.75;
|
sky.haze_height = 0.75;
|
||||||
sky.haze_smoothing = 0.3;
|
sky.haze_smoothing = 0.3;
|
||||||
|
sky.sun_radius = 0.02;
|
||||||
skySetDefinition(sky);
|
skySetDefinition(sky);
|
||||||
|
|
||||||
noise = noiseCreateGenerator();
|
noise = noiseCreateGenerator();
|
||||||
|
|
|
@ -14,9 +14,9 @@ static Color _cbPreviewHorizon(SmallPreview* preview, double x, double y, double
|
||||||
Vector3 eye = {0.0, 0.0, 0.0};
|
Vector3 eye = {0.0, 0.0, 0.0};
|
||||||
Vector3 look;
|
Vector3 look;
|
||||||
|
|
||||||
look.x = x;
|
look.x = cos(M_PI * (x / 1.28 + 0.5)) * cos(M_PI * (y / 2.56));
|
||||||
look.y = -y;
|
look.y = -sin(M_PI * (y / 2.56));
|
||||||
look.z = 1.0;
|
look.z = sin(M_PI * (x / 1.28 + 0.5)) * cos(M_PI * (y / 2.56));
|
||||||
|
|
||||||
return skyGetColorCustom(eye, look, &_definition, NULL, NULL);
|
return skyGetColorCustom(eye, look, &_definition, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ void guiSkyInit()
|
||||||
|
|
||||||
/* Configs */
|
/* Configs */
|
||||||
gtk_range_set_range(GTK_RANGE(GET_WIDGET("sky_daytime")), 0.0, 1.0);
|
gtk_range_set_range(GTK_RANGE(GET_WIDGET("sky_daytime")), 0.0, 1.0);
|
||||||
gtk_range_set_range(GTK_RANGE(GET_WIDGET("sky_sun_size")), 0.0, 1.0);
|
gtk_range_set_range(GTK_RANGE(GET_WIDGET("sky_sun_size")), 0.0, 0.3);
|
||||||
gtk_range_set_range(GTK_RANGE(GET_WIDGET("sky_haze_height")), 0.0, 1.0);
|
gtk_range_set_range(GTK_RANGE(GET_WIDGET("sky_haze_height")), 0.0, 1.0);
|
||||||
gtk_range_set_range(GTK_RANGE(GET_WIDGET("sky_haze_smoothing")), 0.0, 1.0);
|
gtk_range_set_range(GTK_RANGE(GET_WIDGET("sky_haze_smoothing")), 0.0, 1.0);
|
||||||
|
|
||||||
|
|
|
@ -103,12 +103,12 @@ int main(int argc, char** argv)
|
||||||
ilInit();
|
ilInit();
|
||||||
iluInit();
|
iluInit();
|
||||||
|
|
||||||
cameraSetLocation(2.0, 5.0, 10.0);
|
cameraSetLocation(-12.0, 5.0, 2.0);
|
||||||
cameraSetTarget(0.0, 5.0, 0.0);
|
cameraSetTarget(0.0, 5.0, 0.0);
|
||||||
|
|
||||||
autoInit();
|
autoInit();
|
||||||
guiInit();
|
guiInit();
|
||||||
|
|
||||||
autoSetRenderQuality(5);
|
autoSetRenderQuality(5);
|
||||||
autoGenRealisticLandscape(0);
|
autoGenRealisticLandscape(0);
|
||||||
autoSetDaytime(8, 30);
|
autoSetDaytime(8, 30);
|
||||||
|
|
|
@ -92,7 +92,7 @@ void renderSetSize(int width, int height)
|
||||||
_dirty_down = render_height;
|
_dirty_down = render_height;
|
||||||
_dirty_up = -1;
|
_dirty_up = -1;
|
||||||
_dirty_count = 0;
|
_dirty_count = 0;
|
||||||
|
|
||||||
_pixel_count = render_width * render_height;
|
_pixel_count = render_width * render_height;
|
||||||
|
|
||||||
for (y = 0; y < height; y++)
|
for (y = 0; y < height; y++)
|
||||||
|
@ -134,7 +134,7 @@ void renderClear()
|
||||||
|
|
||||||
scanline_left = 0;
|
scanline_left = 0;
|
||||||
scanline_right = render_width - 1;
|
scanline_right = render_width - 1;
|
||||||
|
|
||||||
_progress = 0.0;
|
_progress = 0.0;
|
||||||
_interrupt = 0;
|
_interrupt = 0;
|
||||||
|
|
||||||
|
@ -682,7 +682,7 @@ void renderPostProcess(int nbchunks)
|
||||||
chunks[i].interrupt = 1;
|
chunks[i].interrupt = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (y < ny && !chunks[i].thread && !_interrupt)
|
if (y < ny && !chunks[i].thread && !_interrupt)
|
||||||
{
|
{
|
||||||
chunks[i].finished = 0;
|
chunks[i].finished = 0;
|
||||||
|
|
32
src/sky.c
32
src/sky.c
|
@ -99,6 +99,10 @@ SkyDefinition skyGetDefinition()
|
||||||
|
|
||||||
Color skyGetColorCustom(Vector3 eye, Vector3 look, SkyDefinition* definition, SkyQuality* quality, SkyEnvironment* environment)
|
Color skyGetColorCustom(Vector3 eye, Vector3 look, SkyDefinition* definition, SkyQuality* quality, SkyEnvironment* environment)
|
||||||
{
|
{
|
||||||
|
double sun_angle, dist;
|
||||||
|
Vector3 sun_position;
|
||||||
|
Color sun_color, sky_color;
|
||||||
|
|
||||||
if (definition == NULL)
|
if (definition == NULL)
|
||||||
{
|
{
|
||||||
definition = &_definition;
|
definition = &_definition;
|
||||||
|
@ -112,8 +116,34 @@ Color skyGetColorCustom(Vector3 eye, Vector3 look, SkyDefinition* definition, Sk
|
||||||
environment = &_environment;
|
environment = &_environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sun_angle = (definition->daytime + 0.75) * M_PI * 2.0;
|
||||||
|
sun_position.x = cos(sun_angle);
|
||||||
|
sun_position.y = sin(sun_angle);
|
||||||
|
sun_position.z = 0.0;
|
||||||
|
|
||||||
look = v3Normalize(look);
|
look = v3Normalize(look);
|
||||||
return colorGradationGet(&definition->_sky_gradation, look.y * 0.5 + 0.5);
|
dist = v3Norm(v3Sub(look, sun_position));
|
||||||
|
|
||||||
|
sky_color = colorGradationGet(&definition->_sky_gradation, look.y * 0.5 + 0.5);
|
||||||
|
if (dist < definition->sun_radius)
|
||||||
|
{
|
||||||
|
dist = dist / definition->sun_radius;
|
||||||
|
sun_color = colorGradationGet(&definition->sun_color, definition->daytime);
|
||||||
|
if (dist < 0.9)
|
||||||
|
{
|
||||||
|
return sun_color;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sun_color.a = (1.0 - dist) / 0.1;
|
||||||
|
colorMask(&sky_color, &sun_color);
|
||||||
|
return sky_color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return sky_color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Color skyGetColor(Vector3 eye, Vector3 look)
|
Color skyGetColor(Vector3 eye, Vector3 look)
|
||||||
|
|
Loading…
Reference in a new issue