20 #ifndef ANTKEEPER_RENDER_SKY_PASS_HPP
21 #define ANTKEEPER_RENDER_SKY_PASS_HPP
81 return m_transmittance_lut_sample_count;
87 return m_transmittance_lut_resolution;
126 return m_multiscattering_lut_direction_sample_count;
132 return m_multiscattering_lut_scatter_sample_count;
138 return m_multiscattering_lut_resolution;
167 return m_luminance_lut_sample_count;
173 return m_luminance_lut_resolution;
212 void set_sky_probe(std::shared_ptr<scene::light_probe> probe);
225 void rebuild_transmittance_lut_framebuffer();
226 void rebuild_transmittance_lut_shader_program();
227 void rebuild_transmittance_lut_command_buffer();
228 void rebuild_multiscattering_lut_framebuffer();
229 void rebuild_multiscattering_lut_shader_program();
230 void rebuild_multiscattering_lut_command_buffer();
231 void rebuild_luminance_lut_framebuffer();
232 void rebuild_luminance_lut_shader_program();
233 void rebuild_luminance_lut_command_buffer();
235 void rebuild_sky_lut_command_buffer();
236 void rebuild_sky_probe_command_buffer();
238 std::shared_ptr<gl::sampler> m_lut_sampler;
239 std::unique_ptr<gl::vertex_array> m_vertex_array;
242 std::uint16_t m_transmittance_lut_sample_count{40};
244 std::shared_ptr<gl::texture_2d> m_transmittance_lut_texture;
245 std::shared_ptr<gl::framebuffer> m_transmittance_lut_framebuffer;
246 std::shared_ptr<gl::shader_template> m_transmittance_lut_shader_template;
247 std::unique_ptr<gl::shader_program> m_transmittance_lut_shader_program;
248 std::vector<std::function<void()>> m_transmittance_lut_command_buffer;
249 bool m_render_transmittance_lut{
false};
252 std::uint16_t m_multiscattering_lut_direction_sample_count{64};
253 std::uint16_t m_multiscattering_lut_scatter_sample_count{20};
255 std::shared_ptr<gl::texture_2d> m_multiscattering_lut_texture;
256 std::shared_ptr<gl::framebuffer> m_multiscattering_lut_framebuffer;
257 std::shared_ptr<gl::shader_template> m_multiscattering_lut_shader_template;
258 std::unique_ptr<gl::shader_program> m_multiscattering_lut_shader_program;
259 std::vector<std::function<void()>> m_multiscattering_lut_command_buffer;
260 bool m_render_multiscattering_lut{
false};
263 std::uint16_t m_luminance_lut_sample_count{30};
265 std::shared_ptr<gl::texture_2d> m_luminance_lut_texture;
266 std::shared_ptr<gl::framebuffer> m_luminance_lut_framebuffer;
267 std::shared_ptr<gl::shader_template> m_luminance_lut_shader_template;
268 std::unique_ptr<gl::shader_program> m_luminance_lut_shader_program;
269 std::vector<std::function<void()>> m_luminance_lut_command_buffer;
270 bool m_render_luminance_lut{
false};
273 std::shared_ptr<scene::light_probe> m_sky_probe;
274 std::vector<std::unique_ptr<gl::framebuffer>> m_sky_probe_framebuffers;
275 std::shared_ptr<gl::shader_template> m_sky_probe_shader_template;
276 std::unique_ptr<gl::shader_program> m_sky_probe_shader_program;
277 std::vector<std::function<void()>> m_sky_probe_command_buffer;
282 float camera_exposure;
284 std::shared_ptr<gl::shader_program> sky_shader_program;
302 std::shared_ptr<gl::shader_program> moon_shader_program;
317 std::shared_ptr<render::model> sky_model;
318 const material* sky_material;
322 std::size_t sky_model_vertex_offset{};
323 std::size_t sky_model_vertex_stride{};
324 std::uint32_t sky_model_first_vertex{};
325 std::uint32_t sky_model_vertex_count{};
327 std::shared_ptr<render::model> moon_model;
328 const material* moon_material;
332 std::size_t moon_model_vertex_offset{};
333 std::size_t moon_model_vertex_stride{};
334 std::uint32_t moon_model_first_vertex{};
335 std::uint32_t moon_model_vertex_count{};
336 std::shared_ptr<gl::texture_2d> m_moon_albedo_map;
337 std::shared_ptr<gl::texture_2d> m_moon_normal_map;
339 std::shared_ptr<render::model> stars_model;
340 const material* star_material;
344 std::size_t stars_model_vertex_offset{};
345 std::size_t stars_model_vertex_stride{};
346 std::uint32_t stars_model_first_vertex{};
347 std::uint32_t stars_model_vertex_count{};
348 std::unique_ptr<gl::shader_program> star_shader_program;
372 float sun_angular_radius;
373 float atmosphere_upper_limit;
375 float observer_elevation;
386 std::uint32_t m_layer_mask{1};
Graphics pipeline interface.
Vertex arrays describes how vertex input attributes are stored in vertex buffers.
Vertex buffer object (VBO).
void set_magnification(float scale)
void set_sky_probe(std::shared_ptr< scene::light_probe > probe)
void set_luminance_lut_sample_count(std::uint16_t count)
Sets the number of luminance integration samples.
void set_mie_parameters(float scale_height, float scattering, float extinction, float anisotropy)
void set_moon_planetlight_direction(const math::fvec3 &direction)
void set_multiscattering_lut_direction_sample_count(std::uint16_t count)
Sets the number of multiscattering directions to sample.
void set_sun_position(const math::fvec3 &position)
const math::vec2< std::uint16_t > & get_transmittance_lut_resolution() const noexcept
Returns the resolution of the transmittance LUT texture, in pixels.
void set_ground_albedo(const math::fvec3 &albedo)
void set_transmittance_lut_resolution(const math::vec2< std::uint16_t > &resolution)
Sets the resolution of the transmittance LUT.
void set_rayleigh_parameters(float scale_height, const math::fvec3 &scattering)
void set_moon_sunlight_direction(const math::fvec3 &direction)
void set_ozone_parameters(float lower_limit, float upper_limit, float mode, const math::fvec3 &absorption)
void set_multiscattering_lut_scatter_sample_count(std::uint16_t count)
Sets the number of multiscattering scatter events to sample per sample direction.
void set_transmittance_lut_sample_count(std::uint16_t count)
Sets the number of transmittance integration samples.
void set_airglow_luminance(const math::fvec3 &luminance)
void set_observer_elevation(float elevation)
void set_multiscattering_lut_resolution(const math::vec2< std::uint16_t > &resolution)
Sets the resolution of the multiscattering LUT.
void set_moon_sunlight_illuminance(const math::fvec3 &illuminance)
constexpr void set_layer_mask(std::uint32_t mask) noexcept
Sets the layer mask of the sky.
void set_moon_rotation(const math::fquat &rotation)
void set_icrf_to_eus(const math::se3< float > &transformation)
void set_moon_model(std::shared_ptr< render::model > model)
void set_atmosphere_upper_limit(float limit)
void set_luminance_lut_resolution(const math::vec2< std::uint16_t > &resolution)
Sets the resolution of the luminance LUT.
void render(render::context &ctx) override
void set_sun_illuminance(const math::fvec3 &illuminance, const math::fvec3 &transmitted_illuminance)
std::uint16_t get_luminance_lut_sample_count() const noexcept
Returns the number of luminance integration samples.
void set_moon_angular_radius(float angular_radius)
void set_moon_planetlight_illuminance(const math::fvec3 &illuminance)
void set_sun_angular_radius(float radius)
sky_pass(gl::pipeline *pipeline, const gl::framebuffer *framebuffer, resource_manager *resource_manager)
std::uint16_t get_multiscattering_lut_scatter_sample_count() const noexcept
Returns the number of multiscattering scatter samples per direction.
void set_moon_position(const math::fvec3 &position)
virtual ~sky_pass()=default
void set_moon_illuminance(const math::fvec3 &illuminance, const math::fvec3 &transmitted_illuminance)
void set_sky_model(std::shared_ptr< render::model > model)
const math::vec2< std::uint16_t > & get_luminance_lut_resolution() const noexcept
Returns the resolution of the luminance LUT texture, in pixels.
void set_sun_luminance(const math::fvec3 &luminance)
const math::vec2< std::uint16_t > & get_multiscattering_lut_resolution() const noexcept
Returns the resolution of the multiscattering LUT texture, in pixels.
void set_planet_radius(float radius)
std::uint16_t get_transmittance_lut_sample_count() const noexcept
Returns the number of transmittance integration samples.
void set_stars_model(std::shared_ptr< render::model > model)
std::uint16_t get_multiscattering_lut_direction_sample_count() const noexcept
Returns the number of multiscattering direction samples.
Manages the loading, caching, and saving of resources.
Container which stores two states along with an interpolator, for quick and easy tween<T,...
T angular_radius(T radius, T distance)
Finds the angular radius of a celestial object, given its radius and distance.
constexpr int count(T x) noexcept
Returns the number of set bits in a value, known as a population count or Hamming weight.
primitive_topology
Primitive topologies.
quaternion< T > rotation(const vec3< T > &from, const vec3< T > &to, T tolerance=T{1e-6})
Constructs a quaternion representing the minimum rotation from one direction to another direction.
constexpr mat4< T > scale(const vec3< T > &v)
Constructs a scale matrix.
T extinction(T scattering, T albedo)
Calculates an extinction coefficient.
T absorption(T scattering, T albedo)
Calculates an absorption coefficient.
T scattering(T density, T polarization, T wavelength)
Calculates a wavelength-dependent scattering coefficient.
@ position
Vertex position (vec3)
Quaternion composed of a real scalar part and imaginary vector part.
SE(3) proper rigid transformation (rototranslation).