Skip to content

Commit

Permalink
Keep sun irradiance constant when changing distance and size�
Browse files Browse the repository at this point in the history
  • Loading branch information
mororo250 committed Jul 9, 2020
1 parent 1a427e2 commit 74b9f3d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
13 changes: 0 additions & 13 deletions sandbox/settings/appleseed.studio.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,6 @@
<parameter name="tile_ordering" value="spiral" />
</parameters>
<parameters name="ui">
<parameters name="file_dialog">
<parameters name="frames">
<parameter name="last_directory" value="D:\appleseed-scenes" />
<parameter name="selected_filter" value="JPEG Files (*.jpg *.jpe *.jpeg *.jif *.jfif *.jfi)" />
</parameters>
<parameters name="light_paths">
<parameter name="selected_filter" value="" />
</parameters>
<parameters name="projects">
<parameter name="last_directory" value="D:\appleseed\sandbox\tests\test scenes\light importance multipliers" />
<parameter name="selected_filter" value="Project Files (*.appleseed *.appleseedz)" />
</parameters>
</parameters>
<parameters name="render_region">
<parameter name="triggers_rendering" value="true" />
</parameters>
Expand Down
7 changes: 5 additions & 2 deletions src/appleseed/renderer/modeling/light/sunlight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ bool SunLight::on_frame_begin(
m_values.m_size_multiplier = 1.0f;
}

// Keep sun's irradiance constant for different sizes and distances.
m_values.m_radiance_multiplier = 1.0f / m_values.m_size_multiplier * m_values.m_distance / 149.6f;

// Compute the Sun's solid angle.
// Reference: https://en.wikipedia.org/wiki/Solid_angle#Sun_and_Moon
m_sun_solid_angle = TwoPi<float>() * (1.0f - std::cos(std::atan(SunRadius * m_values.m_size_multiplier / m_values.m_distance)));
Expand Down Expand Up @@ -566,7 +569,7 @@ void SunLight::sample_sun_surface(

outgoing = normalize(target_point - position);
Vector2d test = static_cast<double>(SunRadius * m_values.m_size_multiplier) * p;
float squared_distance_to_center = test[0] * test[0] + test[1] * test[1];
double squared_distance_to_center = test[0] * test[0] + test[1] * test[1];


RegularSpectrum31f radiance;
Expand All @@ -575,7 +578,7 @@ void SunLight::sample_sun_surface(
m_values.m_turbidity,
m_values.m_radiance_multiplier,
radiance,
squared_distance_to_center);
static_cast<float>(squared_distance_to_center));

value.set(radiance, g_std_lighting_conditions, Spectrum::Illuminance);

Expand Down

0 comments on commit 74b9f3d

Please sign in to comment.