Browse Source

Improve angular radius calculation in astronomy system

master
C. J. Howard 3 years ago
parent
commit
882e0dd787
4 changed files with 10 additions and 10 deletions
  1. +2
    -2
      src/ecs/systems/astronomy-system.cpp
  2. +2
    -2
      src/physics/atmosphere.hpp
  3. +4
    -4
      src/renderer/passes/sky-pass.cpp
  4. +2
    -2
      src/renderer/passes/sky-pass.hpp

+ 2
- 2
src/ecs/systems/astronomy-system.cpp View File

@ -189,8 +189,8 @@ void astronomy_system::update(double t, double dt)
this->sky_pass->set_sun_position(math::type_cast<float>(blackbody_position_topocentric)); this->sky_pass->set_sun_position(math::type_cast<float>(blackbody_position_topocentric));
this->sky_pass->set_sun_color(math::type_cast<float>(blackbody.color * blackbody_illuminance)); this->sky_pass->set_sun_color(math::type_cast<float>(blackbody.color * blackbody_illuminance));
float angular_radius = 2.0 * std::atan2(2.0 * blackbody.radius, 2.0 * blackbody_distance);
this->sky_pass->set_sun_angular_radius(angular_radius);
double blackbody_angular_radius = std::asin((blackbody.radius * 2.0) / (blackbody_distance * 2.0));
this->sky_pass->set_sun_angular_radius(static_cast<float>(blackbody_angular_radius));
} }
} }
}); });

+ 2
- 2
src/physics/atmosphere.hpp View File

@ -48,8 +48,8 @@ T density(T d0, T z, T sh)
/** /**
* Calculates a particle polarization factor used in computing scattering coefficients. * Calculates a particle polarization factor used in computing scattering coefficients.
* *
* @param ior Atmospheric index of refraction at sea level.
* @param density Molecular density at sea level.
* @param ior Atmospheric index of refraction.
* @param density Molecular density.
* @return Polarization factor. * @return Polarization factor.
* *
* @see Elek, Oskar. (2009). Rendering Parametrizable Planetary Atmospheres with Multiple Scattering in Real-Time. * @see Elek, Oskar. (2009). Rendering Parametrizable Planetary Atmospheres with Multiple Scattering in Real-Time.

+ 4
- 4
src/renderer/passes/sky-pass.cpp View File

@ -234,8 +234,8 @@ void sky_pass::render(render_context* context) const
observer_altitude_input->upload(observer_altitude); observer_altitude_input->upload(observer_altitude);
if (sun_direction_input) if (sun_direction_input)
sun_direction_input->upload(sun_direction); sun_direction_input->upload(sun_direction);
if (cos_sun_angular_radius_input)
cos_sun_angular_radius_input->upload(cos_sun_angular_radius);
if (sun_angular_radius_input)
sun_angular_radius_input->upload(sun_angular_radius);
if (sun_color_input) if (sun_color_input)
sun_color_input->upload(sun_color); sun_color_input->upload(sun_color);
if (scale_height_rm_input) if (scale_height_rm_input)
@ -347,7 +347,7 @@ void sky_pass::set_sky_model(const model* model)
observer_altitude_input = sky_shader_program->get_input("observer_altitude"); observer_altitude_input = sky_shader_program->get_input("observer_altitude");
sun_direction_input = sky_shader_program->get_input("sun_direction"); sun_direction_input = sky_shader_program->get_input("sun_direction");
sun_color_input = sky_shader_program->get_input("sun_color"); sun_color_input = sky_shader_program->get_input("sun_color");
cos_sun_angular_radius_input = sky_shader_program->get_input("cos_sun_angular_radius");
sun_angular_radius_input = sky_shader_program->get_input("sun_angular_radius");
scale_height_rm_input = sky_shader_program->get_input("scale_height_rm"); scale_height_rm_input = sky_shader_program->get_input("scale_height_rm");
rayleigh_scattering_input = sky_shader_program->get_input("rayleigh_scattering"); rayleigh_scattering_input = sky_shader_program->get_input("rayleigh_scattering");
mie_scattering_input = sky_shader_program->get_input("mie_scattering"); mie_scattering_input = sky_shader_program->get_input("mie_scattering");
@ -430,7 +430,7 @@ void sky_pass::set_sun_color(const float3& color)
void sky_pass::set_sun_angular_radius(float radius) void sky_pass::set_sun_angular_radius(float radius)
{ {
cos_sun_angular_radius = std::cos(radius);
sun_angular_radius = radius;
} }
void sky_pass::set_observer_altitude(float altitude) void sky_pass::set_observer_altitude(float altitude)

+ 2
- 2
src/renderer/passes/sky-pass.hpp View File

@ -80,7 +80,7 @@ private:
const gl::shader_input* observer_altitude_input; const gl::shader_input* observer_altitude_input;
const gl::shader_input* sun_direction_input; const gl::shader_input* sun_direction_input;
const gl::shader_input* sun_color_input; const gl::shader_input* sun_color_input;
const gl::shader_input* cos_sun_angular_radius_input;
const gl::shader_input* sun_angular_radius_input;
const gl::shader_input* scale_height_rm_input; const gl::shader_input* scale_height_rm_input;
const gl::shader_input* rayleigh_scattering_input; const gl::shader_input* rayleigh_scattering_input;
const gl::shader_input* mie_scattering_input; const gl::shader_input* mie_scattering_input;
@ -128,7 +128,7 @@ private:
tween<float3> topocentric_frame_translation; tween<float3> topocentric_frame_translation;
tween<math::quaternion<float>> topocentric_frame_rotation; tween<math::quaternion<float>> topocentric_frame_rotation;
float cos_sun_angular_radius;
float sun_angular_radius;
float2 scale_height_rm; float2 scale_height_rm;
float3 rayleigh_scattering; float3 rayleigh_scattering;
float3 mie_scattering; float3 mie_scattering;

Loading…
Cancel
Save