21 #include <engine/config.hpp>
41 #include <engine/config.hpp>
62 else if (!
b->material)
75 return (
a->depth <
b->depth);
93 const std::size_t hash_a =
a->material->hash();
94 const std::size_t hash_b =
b->material->hash();
99 return (hash_a < hash_b);
104 if (
a->layer_mask !=
b->layer_mask)
106 return (
a->layer_mask <
b->layer_mask);
111 return (
a->vertex_array <
b->vertex_array);
121 pass(pipeline, framebuffer)
146 static_cast<float>(viewport_dimensions[0]),
147 static_cast<float>(viewport_dimensions[1])
153 std::size_t active_material_hash = 0;
154 bool active_two_sided =
false;
156 std::size_t active_cache_key = 0;
157 shader_cache_entry* active_cache_entry =
nullptr;
158 std::uint32_t active_layer_mask = 0;
159 std::size_t active_lighting_state_hash = 0;
162 evaluate_camera(ctx);
166 std::sort(std::execution::par_unseq, ctx.
operations.begin(), ctx.
operations.end(), operation_compare);
174 if (!fallback_material)
192 if (active_material !=
material || active_lighting_state_hash != lighting_state_hash)
245 if (active_cache_key != cache_key)
248 if (
auto i = shader_cache.find(cache_key); i != shader_cache.end())
250 active_cache_entry = &i->second;
255 active_cache_entry = &shader_cache[cache_key];
257 build_shader_command_buffer(active_cache_entry->shader_command_buffer, *active_cache_entry->shader_program);
258 build_geometry_command_buffer(active_cache_entry->geometry_command_buffer, *active_cache_entry->shader_program);
264 for (
const auto&
command: active_cache_entry->shader_command_buffer)
269 active_cache_key = cache_key;
273 std::vector<std::function<void()>>* material_command_buffer;
274 if (
auto i = active_cache_entry->material_command_buffers.find(
material); i != active_cache_entry->material_command_buffers.end())
276 material_command_buffer = &i->second;
280 material_command_buffer = &active_cache_entry->material_command_buffers[
material];
281 build_material_command_buffer(*material_command_buffer, *active_cache_entry->shader_program, *
material);
287 for (
const auto&
command: *material_command_buffer)
293 active_lighting_state_hash = lighting_state_hash;
301 model_view[3] -= view_translation;
302 model_view = view_rotation * model_view;
308 for (
const auto&
command: active_cache_entry->geometry_command_buffer)
324 this->fallback_material = fallback;
339 void material_pass::evaluate_lighting(
const render::context& ctx, std::uint32_t layer_mask)
342 light_probe_count = 0;
343 directional_light_count = 0;
344 directional_shadow_count = 0;
345 spot_light_count = 0;
346 point_light_count = 0;
347 rectangle_light_count = 0;
352 if (!(object->get_layer_mask() & layer_mask))
357 if (!light_probe_count)
369 if (!(object->get_layer_mask() & layer_mask))
383 const std::size_t index = directional_light_count;
385 ++directional_light_count;
386 if (directional_light_count > directional_light_colors.size())
388 directional_light_colors.resize(directional_light_count);
389 directional_light_directions.resize(directional_light_count);
398 const std::size_t index = directional_shadow_count;
400 ++directional_shadow_count;
401 if (directional_shadow_count > directional_shadow_maps.size())
403 directional_shadow_maps.resize(directional_shadow_count);
404 directional_shadow_splits.resize(directional_shadow_count);
405 directional_shadow_fade_ranges.resize(directional_shadow_count);
406 directional_shadow_matrices.resize(directional_shadow_count);
422 const std::size_t index = spot_light_count;
425 if (spot_light_count > spot_light_colors.size())
427 spot_light_colors.resize(spot_light_count);
428 spot_light_positions.resize(spot_light_count);
429 spot_light_directions.resize(spot_light_count);
430 spot_light_cutoffs.resize(spot_light_count);
445 const std::size_t index = point_light_count;
448 if (point_light_count > point_light_colors.size())
450 point_light_colors.resize(point_light_count);
451 point_light_positions.resize(point_light_count);
465 const std::size_t index = rectangle_light_count;
467 ++rectangle_light_count;
468 if (rectangle_light_count > rectangle_light_colors.size())
470 rectangle_light_colors.resize(rectangle_light_count);
471 rectangle_light_corners.resize(rectangle_light_count * 4);
476 const auto corners = rectangle_light.
get_corners();
477 for (std::size_t i = 0;
i < 4; ++
i)
491 lighting_state_hash = std::hash<std::size_t>{}(light_probe_count);
492 lighting_state_hash =
hash_combine(lighting_state_hash, std::hash<std::size_t>{}(directional_light_count));
493 lighting_state_hash =
hash_combine(lighting_state_hash, std::hash<std::size_t>{}(directional_shadow_count));
494 lighting_state_hash =
hash_combine(lighting_state_hash, std::hash<std::size_t>{}(point_light_count));
495 lighting_state_hash =
hash_combine(lighting_state_hash, std::hash<std::size_t>{}(spot_light_count));
496 lighting_state_hash =
hash_combine(lighting_state_hash, std::hash<std::size_t>{}(rectangle_light_count));
503 subframe = ctx.
alpha;
508 static_cast<float>(viewport_dimensions[0]),
509 static_cast<float>(viewport_dimensions[1])
517 std::unordered_map<std::string, std::string> definitions;
529 definitions[
"FRAGMENT_OUTPUT_COLOR"] =
"0";
531 definitions[
"LIGHT_PROBE_COUNT"] = std::to_string(light_probe_count);
532 definitions[
"DIRECTIONAL_LIGHT_COUNT"] = std::to_string(directional_light_count);
533 definitions[
"DIRECTIONAL_SHADOW_COUNT"] = std::to_string(directional_shadow_count);
534 definitions[
"POINT_LIGHT_COUNT"] = std::to_string(point_light_count);
535 definitions[
"SPOT_LIGHT_COUNT"] = std::to_string(spot_light_count);
536 definitions[
"RECTANGLE_LIGHT_COUNT"] = std::to_string(rectangle_light_count);
540 definitions[
"MASKED_OPACITY"] =
"1";
543 auto shader_program = shader_template.
build(definitions);
545 if (!shader_program->linked())
547 debug::log_error(
"Failed to link material shader program: {}", shader_program->info());
551 return shader_program;
554 void material_pass::build_shader_command_buffer(std::vector<std::function<
void()>>& command_buffer,
const gl::shader_program& shader_program)
const
560 if (
auto view_var = shader_program.
variable(
"view"))
562 command_buffer.emplace_back([&, view_var](){view_var->update(*view);});
564 if (
auto inv_view_var = shader_program.
variable(
"inv_view"))
566 command_buffer.emplace_back([&, inv_view_var](){inv_view_var->update(*inv_view);});
568 if (
auto projection_var = shader_program.
variable(
"projection"))
570 command_buffer.emplace_back([&, projection_var](){projection_var->update(*projection);});
572 if (
auto view_projection_var = shader_program.
variable(
"view_projection"))
574 command_buffer.emplace_back([&, view_projection_var](){view_projection_var->update(*view_projection);});
576 if (
auto camera_position_var = shader_program.
variable(
"camera_position"))
578 command_buffer.emplace_back([&, camera_position_var](){camera_position_var->update(*camera_position);});
580 if (
auto camera_exposure_var = shader_program.
variable(
"camera_exposure"))
582 command_buffer.emplace_back([&, camera_exposure_var](){camera_exposure_var->update(camera_exposure);});
586 if (
auto brdf_lut_var = shader_program.
variable(
"brdf_lut"))
588 command_buffer.emplace_back
592 brdf_lut_var->update(*brdf_lut);
598 if (light_probe_count)
600 if (
auto light_probe_luminance_texture_var = shader_program.
variable(
"light_probe_luminance_texture"))
602 command_buffer.emplace_back
604 [&, light_probe_luminance_texture_var]()
606 light_probe_luminance_texture_var->update(*light_probe_luminance_texture);
611 if (
auto light_probe_luminance_mip_scale_var = shader_program.
variable(
"light_probe_luminance_mip_scale"))
613 command_buffer.emplace_back
615 [&, light_probe_luminance_mip_scale_var]()
617 light_probe_luminance_mip_scale_var->update(std::max<float>(
static_cast<float>(light_probe_luminance_texture->
get_image_view()->get_mip_level_count()) - 4.0f, 0.0f));
622 if (
auto light_probe_illuminance_texture_var = shader_program.
variable(
"light_probe_illuminance_texture"))
624 command_buffer.emplace_back
626 [&, light_probe_illuminance_texture_var]()
628 light_probe_illuminance_texture_var->update(*light_probe_illuminance_texture);
635 if (
auto ltc_lut_1_var = shader_program.
variable(
"ltc_lut_1"))
637 if (
auto ltc_lut_2_var = shader_program.
variable(
"ltc_lut_2"))
639 command_buffer.emplace_back
641 [&, ltc_lut_1_var, ltc_lut_2_var]()
643 ltc_lut_1_var->update(*ltc_lut_1);
644 ltc_lut_2_var->update(*ltc_lut_2);
649 if (rectangle_light_count)
651 if (
auto rectangle_light_colors_var = shader_program.
variable(
"rectangle_light_colors"))
653 auto rectangle_light_corners_var = shader_program.
variable(
"rectangle_light_corners");
655 if (rectangle_light_corners_var)
657 command_buffer.emplace_back
659 [&, rectangle_light_colors_var, rectangle_light_corners_var]()
661 rectangle_light_colors_var->update(std::span<const math::fvec3>{rectangle_light_colors.data(), rectangle_light_count});
662 rectangle_light_corners_var->update(std::span<const math::fvec3>{rectangle_light_corners.data(), rectangle_light_count * 4});
670 if (directional_light_count)
672 if (
auto directional_light_colors_var = shader_program.
variable(
"directional_light_colors"))
674 if (
auto directional_light_directions_var = shader_program.
variable(
"directional_light_directions"))
676 command_buffer.emplace_back
678 [&, directional_light_colors_var, directional_light_directions_var]()
680 directional_light_colors_var->update(std::span<const math::fvec3>{directional_light_colors.data(), directional_light_count});
681 directional_light_directions_var->update(std::span<const math::fvec3>{directional_light_directions.data(), directional_light_count});
689 if (directional_shadow_count)
691 if (
auto directional_shadow_maps_var = shader_program.
variable(
"directional_shadow_maps"))
693 auto directional_shadow_splits_var = shader_program.
variable(
"directional_shadow_splits");
694 auto directional_shadow_fade_ranges_var = shader_program.
variable(
"directional_shadow_fade_ranges");
695 auto directional_shadow_matrices_var = shader_program.
variable(
"directional_shadow_matrices");
697 if (directional_shadow_maps_var && directional_shadow_splits_var && directional_shadow_fade_ranges_var && directional_shadow_matrices_var)
699 command_buffer.emplace_back
701 [&, directional_shadow_maps_var, directional_shadow_splits_var, directional_shadow_fade_ranges_var, directional_shadow_matrices_var]()
703 directional_shadow_maps_var->update(std::span<const gl::texture_2d* const>{directional_shadow_maps.data(), directional_shadow_count});
706 for (std::size_t i = 0;
i < directional_shadow_count; ++
i)
708 directional_shadow_splits_var->update(directional_shadow_splits[i], i);
709 directional_shadow_fade_ranges_var->update(directional_shadow_fade_ranges[i], i);
710 directional_shadow_matrices_var->update(directional_shadow_matrices[i],
offset);
711 offset += directional_shadow_matrices[
i].size();
720 if (point_light_count)
722 if (
auto point_light_colors_var = shader_program.
variable(
"point_light_colors"))
724 auto point_light_positions_var = shader_program.
variable(
"point_light_positions");
726 if (point_light_positions_var)
728 command_buffer.emplace_back
730 [&, point_light_colors_var, point_light_positions_var]()
732 point_light_colors_var->update(std::span<const math::fvec3>{point_light_colors.data(), point_light_count});
733 point_light_positions_var->update(std::span<const math::fvec3>{point_light_positions.data(), point_light_count});
741 if (spot_light_count)
743 if (
auto spot_light_colors_var = shader_program.
variable(
"spot_light_colors"))
745 auto spot_light_positions_var = shader_program.
variable(
"spot_light_positions");
746 auto spot_light_directions_var = shader_program.
variable(
"spot_light_directions");
747 auto spot_light_cutoffs_var = shader_program.
variable(
"spot_light_cutoffs");
749 if (spot_light_positions_var && spot_light_directions_var && spot_light_cutoffs_var)
751 command_buffer.emplace_back
753 [&, spot_light_colors_var, spot_light_positions_var, spot_light_directions_var, spot_light_cutoffs_var]()
755 spot_light_colors_var->update(std::span<const math::fvec3>{spot_light_colors.data(), spot_light_count});
756 spot_light_positions_var->update(std::span<const math::fvec3>{spot_light_positions.data(), spot_light_count});
757 spot_light_directions_var->update(std::span<const math::fvec3>{spot_light_directions.data(), spot_light_count});
758 spot_light_cutoffs_var->update(std::span<const math::fvec2>{spot_light_cutoffs.data(), spot_light_count});
766 if (
auto time_var = shader_program.
variable(
"time"))
768 command_buffer.emplace_back([&, time_var](){time_var->update(time);});
772 if (
auto timestep_var = shader_program.
variable(
"timestep"))
774 command_buffer.emplace_back([&, timestep_var](){timestep_var->update(timestep);});
778 if (
auto frame_var = shader_program.
variable(
"frame"))
780 command_buffer.emplace_back([&, frame_var](){frame_var->update(frame);});
784 if (
auto subframe_var = shader_program.
variable(
"subframe"))
786 command_buffer.emplace_back([&, subframe_var](){subframe_var->update(subframe);});
790 if (
auto resolution_var = shader_program.
variable(
"resolution"))
792 command_buffer.emplace_back([&, resolution_var](){resolution_var->update(resolution);});
796 if (
auto mouse_position_var = shader_program.
variable(
"mouse_position"))
798 command_buffer.emplace_back([&, mouse_position_var](){mouse_position_var->update(mouse_position);});
802 void material_pass::build_geometry_command_buffer(std::vector<std::function<
void()>>& command_buffer,
const gl::shader_program& shader_program)
const
805 if (
auto model_var = shader_program.
variable(
"model"))
807 command_buffer.emplace_back([&, model_var](){model_var->update(*model);});
811 if (
auto normal_model_var = shader_program.
variable(
"normal_model"))
813 command_buffer.emplace_back
815 [&, normal_model_var]()
823 auto model_view_var = shader_program.
variable(
"model_view");
824 auto normal_model_view_var = shader_program.
variable(
"normal_model_view");
825 if (model_view_var && normal_model_view_var)
827 command_buffer.emplace_back
829 [&, model_view_var, normal_model_view_var]()
831 model_view_var->update(model_view);
840 command_buffer.emplace_back([&, model_view_var](){model_view_var->update(model_view);});
842 else if (normal_model_view_var)
844 command_buffer.emplace_back
846 [&, normal_model_view_var]()
855 if (
auto model_view_projection_var = shader_program.
variable(
"model_view_projection"))
857 command_buffer.emplace_back([&, model_view_projection_var](){model_view_projection_var->update((*projection) * model_view);});
861 if (
auto matrix_palette_var = shader_program.
variable(
"matrix_palette"))
863 command_buffer.emplace_back([&, matrix_palette_var](){matrix_palette_var->update(matrix_palette);});
867 void material_pass::build_material_command_buffer(std::vector<std::function<
void()>>& command_buffer,
const gl::shader_program& shader_program,
const material& material)
const
869 for (
const auto& [key, material_var]: material.get_variables())
876 const auto shader_var = shader_program.
variable(key);
882 const std::size_t size = std::min<std::size_t>(material_var->size(), shader_var->size());
884 switch (shader_var->type())
902 command_buffer.emplace_back
904 [size, shader_var, material_var = std::static_pointer_cast<matvar_bvec2>(material_var)]()
906 shader_var->update(std::span<const math::bvec2>{material_var->data(), size});
914 command_buffer.emplace_back
916 [size, shader_var, material_var = std::static_pointer_cast<matvar_bvec3>(material_var)]()
918 shader_var->update(std::span<const math::bvec3>{material_var->data(), size});
926 command_buffer.emplace_back
928 [size, shader_var, material_var = std::static_pointer_cast<matvar_bvec4>(material_var)]()
930 shader_var->update(std::span<const math::bvec4>{material_var->data(), size});
938 command_buffer.emplace_back
940 [size, shader_var, material_var = std::static_pointer_cast<matvar_int>(material_var)]()
942 shader_var->update(std::span<const int>{material_var->data(), size});
950 command_buffer.emplace_back
952 [size, shader_var, material_var = std::static_pointer_cast<matvar_ivec2>(material_var)]()
954 shader_var->update(std::span<const math::ivec2>{material_var->data(), size});
962 command_buffer.emplace_back
964 [size, shader_var, material_var = std::static_pointer_cast<matvar_ivec3>(material_var)]()
966 shader_var->update(std::span<const math::ivec3>{material_var->data(), size});
974 command_buffer.emplace_back
976 [size, shader_var, material_var = std::static_pointer_cast<matvar_ivec4>(material_var)]()
978 shader_var->update(std::span<const math::ivec4>{material_var->data(), size});
986 command_buffer.emplace_back
988 [size, shader_var, material_var = std::static_pointer_cast<matvar_uint>(material_var)]()
990 shader_var->update(std::span<const unsigned int>{material_var->data(), size});
998 command_buffer.emplace_back
1000 [size, shader_var, material_var = std::static_pointer_cast<matvar_uvec2>(material_var)]()
1002 shader_var->update(std::span<const math::uvec2>{material_var->data(), size});
1010 command_buffer.emplace_back
1012 [size, shader_var, material_var = std::static_pointer_cast<matvar_uvec3>(material_var)]()
1014 shader_var->update(std::span<const math::uvec3>{material_var->data(), size});
1022 command_buffer.emplace_back
1024 [size, shader_var, material_var = std::static_pointer_cast<matvar_uvec4>(material_var)]()
1026 shader_var->update(std::span<const math::uvec4>{material_var->data(), size});
1034 command_buffer.emplace_back
1036 [size, shader_var, material_var = std::static_pointer_cast<matvar_float>(material_var)]()
1038 shader_var->update(std::span<const float>{material_var->data(), size});
1046 command_buffer.emplace_back
1048 [size, shader_var, material_var = std::static_pointer_cast<matvar_fvec2>(material_var)]()
1050 shader_var->update(std::span<const math::fvec2>{material_var->data(), size});
1058 command_buffer.emplace_back
1060 [size, shader_var, material_var = std::static_pointer_cast<matvar_fvec3>(material_var)]()
1062 shader_var->update(std::span<const math::fvec3>{material_var->data(), size});
1070 command_buffer.emplace_back
1072 [size, shader_var, material_var = std::static_pointer_cast<matvar_fvec4>(material_var)]()
1074 shader_var->update(std::span<const math::fvec4>{material_var->data(), size});
1082 command_buffer.emplace_back
1084 [size, shader_var, material_var = std::static_pointer_cast<matvar_fmat2>(material_var)]()
1086 shader_var->update(std::span<const math::fmat2>{material_var->data(), size});
1094 command_buffer.emplace_back
1096 [size, shader_var, material_var = std::static_pointer_cast<matvar_fmat3>(material_var)]()
1098 shader_var->update(std::span<const math::fmat3>{material_var->data(), size});
1106 command_buffer.emplace_back
1108 [size, shader_var, material_var = std::static_pointer_cast<matvar_fmat4>(material_var)]()
1110 shader_var->update(std::span<const math::fmat4>{material_var->data(), size});
1118 command_buffer.emplace_back
1120 [size, shader_var, material_var = std::static_pointer_cast<matvar_texture_1d>(material_var)]()
1122 shader_var->update(std::span<
const std::shared_ptr<gl::texture_1d>>{material_var->data(), size});
1130 command_buffer.emplace_back
1132 [size, shader_var, material_var = std::static_pointer_cast<matvar_texture_2d>(material_var)]()
1134 shader_var->update(std::span<
const std::shared_ptr<gl::texture_2d>>{material_var->data(), size});
1142 command_buffer.emplace_back
1144 [size, shader_var, material_var = std::static_pointer_cast<matvar_texture_3d>(material_var)]()
1146 shader_var->update(std::span<
const std::shared_ptr<gl::texture_3d>>{material_var->data(), size});
1154 command_buffer.emplace_back
1156 [size, shader_var, material_var = std::static_pointer_cast<matvar_texture_cube>(material_var)]()
1158 shader_var->update(std::span<
const std::shared_ptr<gl::texture_cube>>{material_var->data(), size});
constexpr const std::array< std::uint32_t, 2 > & dimensions() const noexcept
Returns the dimensions of the framebuffer.
Graphics pipeline interface.
void set_primitive_topology(primitive_topology topology)
Sets the primitive topology to use for drawing.
void bind_shader_program(const gl::shader_program *shader_program)
Sets the vertex input.
void bind_framebuffer(const gl::framebuffer *framebuffer)
Sets the vertex input.
void set_color_blend_enabled(bool enabled)
Controls whether blending is enabled for the corresponding color attachment.
void set_cull_mode(cull_mode mode)
Sets the triangle culling mode.
void set_stencil_test_enabled(bool enabled)
Controls whether stencil testing is enabled.
void set_viewport(std::uint32_t first_viewport, std::span< const viewport > viewports)
Sets one or more viewports.
void bind_vertex_buffers(std::uint32_t first_binding, std::span< const vertex_buffer *const > buffers, std::span< const std::size_t > offsets, std::span< const std::size_t > strides)
Binds vertex buffers.
void set_color_blend_equation(const color_blend_equation &equation)
Sets the color blend factors and operations.
void set_depth_compare_op(gl::compare_op compare_op)
Sets the depth comparison operator.
void draw(std::uint32_t vertex_count, std::uint32_t instance_count, std::uint32_t first_vertex, std::uint32_t first_instance)
Draws primitives.
constexpr const std::array< std::uint32_t, 2 > & get_default_framebuffer_dimensions() const noexcept
Returns the dimensions of the default framebuffer.
void set_depth_test_enabled(bool enabled)
Controls whether depth testing is enabled.
void bind_vertex_array(const vertex_array *array)
Binds a vertex array.
Shader program which can be linked to shader objects and executed.
const shader_variable * variable(hash::fnv1a32_t key) const
Returns a pointer to an active shader variable with the given name, or nullptr if not found.
Template used to for generating one or more shader variants from a single source.
std::string configure(gl::shader_stage stage, const dictionary_type &definitions={}) const
Configures shader object source code for a given shader stage and template dictionary.
std::unique_ptr< gl::shader_program > build(const dictionary_type &definitions={}) const
Configures and compiles shader objects, then links them into a shader program.
constexpr const std::shared_ptr< image_view_cube > & get_image_view() const noexcept
Returns the image view.
void set_fallback_material(std::shared_ptr< render::material > fallback)
Sets the material to be used when a render operation is missing a material. If no fallback material i...
void render(render::context &ctx) override
material_pass(gl::pipeline *pipeline, const gl::framebuffer *framebuffer, resource_manager *resource_manager)
A material is associated with exactly one shader program and contains a set of material properties wh...
const std::shared_ptr< gl::shader_template > & get_shader_template() const noexcept
Returns the shader template with which this material is associated.
std::size_t hash() const noexcept
Returns a hash of the material state.
bool is_two_sided() const noexcept
Returns true if the material surface is two-sided, and false otherwise.
material_blend_mode get_blend_mode() const noexcept
Returns the material blend mode.
gl::pipeline * m_pipeline
const gl::framebuffer * m_framebuffer
Manages the loading, caching, and saving of resources.
std::shared_ptr< T > load(const std::filesystem::path &path)
Loads and caches a resource.
constexpr const math::fmat4 & get_projection() const noexcept
Returns the camera's projection matrix.
constexpr const math::fmat4 & get_view() const noexcept
Returns the camera's view matrix.
constexpr const math::fmat4 & get_view_projection() const noexcept
Returns the camera's view-projection matrix.
constexpr float get_exposure_normalization() const noexcept
Returns the camera's exposure normalization factor.
constexpr const math::fmat4 & get_inv_view() const noexcept
Returns the inverse of the camera's view matrix.
const std::vector< object_base * > & get_objects() const noexcept
Returns all objects in the collection.
Light source with parallel rays and constant intensity.
constexpr float get_shadow_fade_range() const noexcept
Returns the distance from the maximum shadow distance at which shadows will begin to fade out.
constexpr bool is_shadow_caster() const noexcept
Returns true if the light casts shadows, false otherwise.
constexpr const std::shared_ptr< gl::framebuffer > & get_shadow_framebuffer() const noexcept
Returns the shadow map framebuffer, of nullptr if no shadow map framebuffer is set.
constexpr const math::fvec3 & get_colored_illuminance() const noexcept
Returns the color-modulated illuminance of the light on a surface perpendicular to the light directio...
constexpr const math::fvec4 & get_shadow_cascade_distances() const noexcept
Returns the array of shadow cascade far clipping plane distances.
constexpr const std::shared_ptr< gl::texture_2d > & get_shadow_texture() const noexcept
Returns the shadow map texture.
constexpr std::span< const math::fmat4 > get_shadow_cascade_matrices() const noexcept
Returns the array of world-space to cascade texture-space transformation matrices.
constexpr const math::fvec3 & get_direction() const noexcept
Returns a unit vector pointing in the light direction.
const std::shared_ptr< gl::texture_cube > & get_luminance_texture() const noexcept
Returns the light probe's luminance texture.
const std::shared_ptr< gl::texture_1d > & get_illuminance_texture() const noexcept
Returns the light probe's illuminance texture.
Abstract base class for light objects.
virtual light_type get_light_type() const noexcept=0
Returns an enumeration denoting the light object type.
Abstract base class for scene objects.
constexpr std::uint32_t get_layer_mask() const noexcept
Returns the layer mask of the object.
constexpr const vector_type & get_translation() const noexcept
Returns the translation of the object.
constexpr const quaternion_type & get_rotation() const noexcept
Returns the rotation of the object.
static const std::atomic< std::size_t > object_type_id
Unique type ID for this scene object type.
Light source that radiates outward from a point.
constexpr const math::fvec3 & get_colored_luminous_flux() const noexcept
Returns the color-modulated luminous flux of the light.
constexpr const math::fvec3 & get_colored_luminance() const noexcept
Returns the color-modulated luminance of the light.
constexpr std::span< const math::fvec3, 4 > get_corners() const noexcept
Returns the world-space positions of the light corners.
Directional cone light source.
const math::fvec2 & get_cosine_cutoff() const noexcept
Returns the cosine of the spot light cutoff angles.
const math::fvec3 & get_luminous_flux() const noexcept
Returns the luminous flux of the spot light, in lm.
const math::fvec3 & get_direction() const noexcept
Returns the direction vector.
constexpr std::uint32_t hash_combine(std::uint32_t x, std::uint32_t y) noexcept
Combines two hash values.
Commands which operate on entity::id components.
log_message< log_message_severity::warning, Args... > log_warning
Formats and logs a warning message.
log_message< log_message_severity::trace, Args... > log_trace
Formats and logs a trace message.
log_message< log_message_severity::error, Args... > log_error
Formats and logs an error message.
@ none
No triangles are discarded.
@ back
Back-facing triangles are discarded.
@ fragment
Fragment shader stage.
@ greater_or_equal
Comparison evaluates reference >= test.
constexpr matrix< T, M, N > transpose(const matrix< T, N, M > &m) noexcept
Calculates the transpose of a matrix.
constexpr matrix< T, N, N > inverse(const matrix< T, N, N > &m) noexcept
Calculates the inverse of a square matrix.
T offset(T longitude)
Calculates the UTC offset at a given longitude.
@ bone_index
Vertex bone indices (uvec4)
@ tangent
Vertex tangent (vec4)
@ target
Vertex morph target (vec3)
@ barycentric
Vertex barycentric coordinates (vec3)
@ normal
Vertex normal (vec3)
@ color
Vertex color (vec4)
@ bone_weight
Vertex bone weights (vec4)
@ uv
Vertex UV texture coordinates (vec2)
@ position
Vertex position (vec3)
material_blend_mode
Material blend modes.
@ opaque
Material is fully opaque.
@ masked
Material has binary masked opacity.
@ translucent
Material is translucent.
@ rectangle
Rectangle light.
@ directional
Directional light.
Viewport position, dimensions, and depth range.
n by m column-major matrix.
const scene::camera * camera
Pointer to the camera.
float alpha
Subframe interpolation factor.
scene::collection * collection
Collection of scene objects being rendered.
float dt
Timestep, in seconds.
std::vector< const operation * > operations
Render operations generated by visible objects.
float t
Current time, in seconds.
std::uint32_t vertex_count
std::uint32_t instance_count
std::span< const math::fmat4 > matrix_palette
std::size_t vertex_offset
std::size_t vertex_stride
std::uint32_t first_instance
gl::primitive_topology primitive_topology
std::uint32_t first_vertex
const gl::vertex_buffer * vertex_buffer
std::shared_ptr< render::material > material
const gl::vertex_array * vertex_array