2#include <ossia/detail/config.hpp>
4#include <ossia/dataflow/texture_port.hpp>
5#include <ossia/detail/flat_map.hpp>
6#include <ossia/detail/small_vector.hpp>
7#include <ossia/detail/variant.hpp>
8#include <ossia/network/value/value.hpp>
25enum class attribute_semantic : uint16_t
35 texcoord1 = texcoord0 + 1,
36 texcoord2 = texcoord0 + 2,
37 texcoord3 = texcoord0 + 3,
38 texcoord4 = texcoord0 + 4,
39 texcoord5 = texcoord0 + 5,
40 texcoord6 = texcoord0 + 6,
41 texcoord7 = texcoord0 + 7,
50 joints1 = joints0 + 1,
53 weights1 = weights0 + 1,
57 morph_normal = morph_position + 1,
58 morph_tangent = morph_position + 2,
59 morph_texcoord = morph_position + 3,
60 morph_color = morph_position + 4,
64 rotation_extra = rotation + 1,
66 uniform_scale = rotation + 3,
69 transform_matrix = rotation + 6,
70 translation = rotation + 7,
74 acceleration = velocity + 1,
78 lifetime = velocity + 5,
79 birth_time = velocity + 6,
80 particle_id = velocity + 7,
82 angular_velocity = velocity + 9,
83 previous_position = velocity + 10,
84 rest_position = velocity + 11,
85 target_position = velocity + 12,
86 previous_velocity = velocity + 13,
87 state = velocity + 14,
88 collision_count = velocity + 15,
89 collision_normal = velocity + 16,
90 sleep = velocity + 17,
94 sprite_rotation = sprite_size + 1,
95 sprite_facing = sprite_size + 2,
96 sprite_index = sprite_size + 3,
97 width = sprite_size + 4,
98 opacity = sprite_size + 5,
99 emissive = sprite_size + 6,
100 emissive_strength = sprite_size + 7,
104 metallic = roughness + 1,
105 ambient_occlusion = roughness + 2,
106 specular = roughness + 3,
107 subsurface = roughness + 4,
108 clearcoat = roughness + 5,
109 clearcoat_roughness = roughness + 6,
110 anisotropy = roughness + 7,
111 anisotropy_direction = roughness + 8,
113 transmission = roughness + 10,
114 thickness = roughness + 11,
115 material_id = roughness + 22,
119 sh_coeffs = sh_dc + 1,
120 covariance_3d = sh_dc + 2,
121 sh_degree = sh_dc + 3,
125 temperature = density + 1,
127 pressure = density + 3,
128 divergence = density + 4,
129 sdf_distance = density + 5,
130 voxel_color = density + 6,
138 group_mask = name + 5,
139 instance_id = name + 6,
144 instance_color0 = 1800,
145 instance_color1 = instance_color0 + 1,
146 instance_color2 = instance_color0 + 2,
147 instance_color3 = instance_color0 + 3,
148 instance_custom0 = instance_color0 + 4,
149 instance_custom1 = instance_color0 + 5,
150 instance_custom2 = instance_color0 + 6,
151 instance_custom3 = instance_color0 + 7,
152 instance_draw_id = instance_color0 + 8,
168OSSIA_EXPORT std::string_view semantic_to_name(attribute_semantic s)
noexcept;
171OSSIA_EXPORT attribute_semantic name_to_semantic(std::string_view name)
noexcept;
177 std::shared_ptr<void> raw_data;
189 ossia::variant<cpu_buffer, gpu_buffer> data;
191 int64_t active_element_count{-1};
196 uint32_t byte_stride{};
243 uint32_t byte_offset = 0;
247 attribute_semantic semantic = attribute_semantic::custom;
254 uint32_t element_byte_size = 0;
255 std::string user_type_name;
261 int64_t byte_offset{};
264 ossia::small_vector<buffer, 2> buffers;
265 ossia::small_vector<binding, 2> bindings;
266 ossia::small_vector<attribute, 2> attributes;
267 ossia::small_vector<input, 2> input;
269 int vertices{}, indices{}, instances{1};
291 enum blend_mode : uint8_t
294 blend_premultiplied_alpha
295 } blend{blend_opaque};
296 bool depth_write{
true};
300 int64_t byte_offset{};
312 uint32_t filter_tag{};
313 uint32_t filter_material_index{};
314 gpu_buffer indirect_count;
317 uint32_t index_or_vertex_count{};
318 uint32_t instance_count{1};
319 uint32_t first_index_or_vertex{};
320 int32_t base_vertex{};
321 uint32_t first_instance{};
323 ossia::small_vector<draw_command, 0> cpu_draw_commands;
324 struct auxiliary_buffer
328 int64_t byte_offset{};
331 ossia::small_vector<auxiliary_buffer, 1> auxiliary;
332 struct auxiliary_texture
335 void* native_handle{};
338 void* sampler_handle{};
340 ossia::small_vector<auxiliary_texture, 2> auxiliary_textures;
341 const auxiliary_buffer* find_auxiliary(std::string_view name)
const noexcept
343 for(
auto& a : auxiliary)
348 const auxiliary_texture* find_auxiliary_texture(std::string_view name)
const noexcept
350 for(
auto& a : auxiliary_textures)
355 const attribute* find(attribute_semantic sem)
const noexcept
357 for(
auto& a : attributes)
358 if(a.semantic == sem)
363 const attribute* find(std::string_view attr_name)
const noexcept
365 for(
auto& a : attributes)
366 if(a.semantic == attribute_semantic::custom && a.name == attr_name)
370 static std::string_view display_name(
const attribute& a)
noexcept
372 if(a.semantic != attribute_semantic::custom)
373 return semantic_to_name(a.semantic);
380 std::vector<geometry> meshes;
381 int64_t dirty_index{};
383using mesh_list_ptr = std::shared_ptr<mesh_list>;
387 1., 0., 0., 0., 0., 1., 0., 0., 0., 0., 1., 0., 0., 0., 0., 1.,
391struct geometry_filter
409 int64_t dirty_index{};
412struct geometry_filter_list
414 std::vector<geometry_filter> filters;
415 int64_t dirty_index{};
417using geometry_filter_list_ptr = std::shared_ptr<geometry_filter_list>;
421 mesh_list_ptr meshes;
422 geometry_filter_list_ptr filters;
424 operator bool() const noexcept {
return meshes && filters; }
425 bool operator==(
const geometry_spec&)
const noexcept =
default;
426 bool operator<(
const geometry_spec& rhs)
const noexcept
428 return (meshes < rhs.meshes) || (meshes == rhs.meshes && filters < rhs.filters);
432struct OSSIA_EXPORT geometry_port
434 static const constexpr int which = 4;
437 dirty_transform = 0x1,
443 geometry_spec geometry;
444 transform3d transform;
448struct geometry_delay_line
450 std::vector<geometry_spec> geometries;
458 uint32_t internal_index{};
459 uint32_t generation{};
461 bool valid() const noexcept {
return size != 0; }
463OSSIA_EXPORT uint64_t mint_stable_id() noexcept;
464struct scene_transform
466 float translation[3]{0.0f, 0.0f, 0.0f};
467 float rotation[4]{0.0f, 0.0f, 0.0f, 1.0f};
468 float scale[3]{1.0f, 1.0f, 1.0f};
472 gpu_slot_ref raw_slot;
475 uint64_t stable_id{};
481 void* native_handle{};
483 int64_t byte_offset{};
484 uint32_t binding_index{};
486 bool valid()
const noexcept {
return native_handle !=
nullptr; }
492 void* native_handle{};
493 uint32_t bindless_index{};
497 enum class filter : uint8_t { nearest, linear };
498 enum class address : uint8_t { repeat, clamp_to_edge, mirror };
499 enum class mipmap : uint8_t { none, nearest, linear };
501 filter mag : 2 = filter::linear;
502 filter
min : 2 = filter::linear;
503 mipmap mip : 2 = mipmap::linear;
504 address u : 2 = address::repeat;
505 address v : 2 = address::repeat;
506 address w : 2 = address::repeat;
508 bool operator==(
const sampler_state&)
const noexcept =
default;
511 bool valid()
const noexcept {
return native_handle !=
nullptr; }
516 std::shared_ptr<const void> data;
519 enum class usage : uint8_t
526 } usage_hint{usage::vertex_buffer};
529struct buffer_resource
531 ossia::variant<buffer_data, gpu_buffer_handle> resource;
532 uint64_t content_hash{};
533 int64_t dirty_index{};
535 bool is_gpu_resident() const noexcept
537 return ossia::get_if<gpu_buffer_handle>(&resource) !=
nullptr;
540using buffer_resource_ptr = std::shared_ptr<const buffer_resource>;
542enum class vertex_format : uint8_t
544 float1, float2, float3, float4,
545 half1, half2, half3, half4,
546 unorm8x1, unorm8x2, unorm8x4,
547 snorm8x1, snorm8x2, snorm8x4,
548 uint8x1, uint8x2, uint8x4,
549 uint16x1, uint16x2, uint16x4,
550 uint32x1, uint32x2, uint32x3, uint32x4,
551 sint8x1, sint8x2, sint8x4,
552 sint16x1, sint16x2, sint16x4,
553 sint32x1, sint32x2, sint32x3, sint32x4,
554 rgb10a2_unorm, rg11b10_float,
558struct vertex_attribute
560 attribute_semantic semantic{};
561 vertex_format format{vertex_format::float3};
562 uint32_t buffer_index{};
563 uint32_t byte_offset{};
564 uint32_t byte_stride{};
565 enum class input_rate : uint8_t { per_vertex, per_instance } rate{};
571 uint32_t element_byte_size = 0;
572 std::string user_type_name;
575enum class primitive_topology : uint8_t
577 points, lines, line_strip, triangles, triangle_strip, triangle_fan,
581enum class index_format : uint8_t { none, uint16, uint32 };
588 bool operator==(
const aabb&)
const noexcept =
default;
594 constexpr bool empty() const noexcept
599 constexpr void expand(
float x,
float y,
float z)
noexcept
608 if(x < min[0])
min[0] = x;
else if(x > max[0])
max[0] = x;
609 if(y < min[1])
min[1] = y;
else if(y > max[1])
max[1] = y;
610 if(z < min[2])
min[2] = z;
else if(z > max[2])
max[2] = z;
614inline aabb compute_aabb_from_positions(
615 const float* positions, std::size_t vertex_count)
noexcept
619 out.min[0] = out.min[1] = out.min[2] = 1.f;
620 out.max[0] = out.max[1] = out.max[2] = -1.f;
621 if(!positions || vertex_count == 0)
623 for(std::size_t i = 0; i < vertex_count; ++i)
625 out.expand(positions[i * 3 + 0], positions[i * 3 + 1], positions[i * 3 + 2]);
630struct material_component;
631using material_component_ptr = std::shared_ptr<const material_component>;
633struct skeleton_component;
634using skeleton_component_ptr = std::shared_ptr<const skeleton_component>;
638 ossia::small_vector<buffer_resource_ptr, 4> vertex_buffers;
639 buffer_resource_ptr index_buffer;
640 ossia::small_vector<vertex_attribute, 8> attributes;
642 primitive_topology topology{primitive_topology::triangles};
643 index_format index_type{index_format::none};
645 uint32_t vertex_count{};
646 uint32_t index_count{};
647 uint32_t first_vertex{};
648 uint32_t first_index{};
649 int32_t vertex_offset{};
651 material_component_ptr material;
653 float line_width{1.0f};
654 gpu_slot_ref raw_slot;
655 uint64_t stable_id{};
656 ossia::small_vector<material_component_ptr, 0> material_variants;
661 buffer_resource_ptr position_deltas;
662 buffer_resource_ptr normal_deltas;
663 buffer_resource_ptr tangent_deltas;
664 float default_weight{0.0f};
667using scene_property_map = ossia::flat_map<std::string, ossia::value>;
671 ossia::small_vector<mesh_primitive, 4> primitives;
672 ossia::small_vector<morph_target, 8> morph_targets;
673 ossia::small_vector<float, 8> morph_weights;
675 skeleton_component_ptr skin;
678 uint8_t lod_level{0};
679 float lod_screen_coverage{0.0f};
681 scene_property_map properties;
682 geometry_spec legacy_geometry;
684 int64_t dirty_index{};
686using mesh_component_ptr = std::shared_ptr<const mesh_component>;
689 std::string file_path;
690 std::shared_ptr<const std::vector<uint8_t>> embedded_data;
691 std::string mime_type;
693 uint64_t content_hash{};
695struct texture_sampler_config
697 texture_address_mode wrap_s : 2 = texture_address_mode::REPEAT;
698 texture_address_mode wrap_t : 2 = texture_address_mode::REPEAT;
699 texture_filter mag_filter : 2 = texture_filter::LINEAR;
700 texture_filter min_filter : 2 = texture_filter::LINEAR;
701 texture_filter mipmap_mode : 2 = texture_filter::LINEAR;
703 constexpr uint32_t hash() const noexcept
705 return uint32_t(wrap_s)
706 | (uint32_t(wrap_t) << 2)
707 | (uint32_t(mag_filter) << 4)
708 | (uint32_t(min_filter) << 6)
709 | (uint32_t(mipmap_mode) << 8);
711 bool operator==(
const texture_sampler_config&)
const noexcept =
default;
715 gpu_texture_handle texture{};
716 uint32_t texcoord_set{0};
718 std::shared_ptr<const texture_source> source;
722 float offset[2]{0.0f, 0.0f};
723 float scale[2]{1.0f, 1.0f};
724 float rotation{0.0f};
726 texture_sampler_config sampler{};
728 bool valid() const noexcept {
return texture.valid() || source; }
730enum class alpha_mode : uint8_t { opaque_, mask, blend };
732struct material_component
734 float base_color_factor[4]{1.0f, 1.0f, 1.0f, 1.0f};
735 texture_ref base_color_texture;
737 float metallic_factor{1.0f};
738 float roughness_factor{1.0f};
739 texture_ref metallic_roughness_texture;
741 texture_ref normal_texture;
742 float normal_scale{1.0f};
744 texture_ref occlusion_texture;
745 float occlusion_strength{1.0f};
747 float emissive_factor[3]{0.0f, 0.0f, 0.0f};
748 texture_ref emissive_texture;
749 float emissive_strength{1.0f};
751 alpha_mode alpha{alpha_mode::opaque_};
752 float alpha_cutoff{0.5f};
753 bool double_sided{
false};
755 struct {
float factor{0.0f}; texture_ref texture; } transmission{};
758 float thickness_factor{0.0f};
759 texture_ref thickness_texture;
760 float attenuation_distance{1e38f};
761 float attenuation_color[3]{1.0f, 1.0f, 1.0f};
769 float color_factor[3]{1.0f, 1.0f, 1.0f};
770 texture_ref color_texture;
776 float roughness_factor{0.0f};
777 texture_ref roughness_texture;
778 texture_ref normal_texture;
779 float normal_scale{1.0f};
783 float color_factor[3]{0.0f, 0.0f, 0.0f};
784 texture_ref color_texture;
785 float roughness_factor{0.0f};
786 texture_ref roughness_texture;
793 float thickness_min{100.0f};
794 float thickness_max{400.0f};
795 texture_ref thickness_texture;
799 float strength{0.0f};
800 float rotation{0.0f};
806 float color_factor[3]{1.0f, 1.0f, 1.0f};
808 texture_ref color_texture;
809 } diffuse_transmission{};
813 bool shadow_caster{
true};
814 bool shadow_receiver{
true};
815 bool reflection_caster{
true};
819 scene_property_map properties;
821 int64_t dirty_index{};
822 gpu_slot_ref raw_slot;
823 uint64_t stable_id{};
825using material_component_ptr = std::shared_ptr<const material_component>;
827enum class light_type : uint8_t
829 directional, point, spot,
830 rect_area, disk_area, sphere_area, cylinder_area,
834enum class light_decay : uint8_t
841struct light_component
843 light_type type{light_type::point};
844 light_decay decay{light_decay::quadratic};
846 float color[3]{1.0f, 1.0f, 1.0f};
847 float intensity{1.0f};
850 float inner_cone_angle{0.0f};
851 float outer_cone_angle{0.7853981f};
858 buffer_resource_ptr ies_profile;
859 std::shared_ptr<const texture_source> environment_texture;
864 float normal_bias{0.01f};
865 uint32_t map_resolution{1024};
866 float near_plane{0.1f};
867 float far_plane{100.0f};
870 int64_t dirty_index{};
871 gpu_slot_ref raw_slot;
872 uint64_t stable_id{};
874using light_component_ptr = std::shared_ptr<const light_component>;
876enum class camera_projection : uint8_t { perspective, orthographic, fulldome };
878struct camera_component
880 camera_projection projection{camera_projection::perspective};
882 float yfov{0.7853981f};
883 float aspect_ratio{1.0f};
885 bool aspect_ratio_set{
false};
894 float focal_length{50.0f};
895 float focus_distance{10.0f};
897 float horizontal_aperture{36.0f};
898 float vertical_aperture{24.0f};
901 bool enable_dof{
false};
903 int64_t dirty_index{};
904 gpu_slot_ref raw_slot;
905 uint64_t stable_id{};
907using camera_component_ptr = std::shared_ptr<const camera_component>;
909struct OSSIA_EXPORT scene_node_id
913 bool operator==(
const scene_node_id&)
const noexcept =
default;
914 bool operator<(
const scene_node_id& rhs)
const noexcept {
return value < rhs.value; }
916 static scene_node_id from_path(std::string_view path)
noexcept;
917 static scene_node_id from_parent(scene_node_id parent, std::string_view name)
noexcept;
923 int32_t parent_index{-1};
924 float inverse_bind_matrix[16]{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};
926 float translation[3]{0, 0, 0};
927 float rotation[4]{0, 0, 0, 1};
928 float scale[3]{1, 1, 1};
931enum class skinning_method : uint8_t
937struct skeleton_component
939 ossia::small_vector<skeleton_joint, 64> joints;
940 buffer_resource_ptr joint_matrices_buffer;
942 ossia::small_vector<scene_node_id, 64> joint_node_ids;
944 skinning_method method{skinning_method::linear_blend};
946 int64_t dirty_index{};
948 int32_t find_joint(std::string_view name)
const noexcept
950 for(int32_t i = 0; i < (int32_t)joints.size(); i++)
951 if(joints[i].name == name)
956using skeleton_component_ptr = std::shared_ptr<const skeleton_component>;
958enum class animation_interpolation : uint8_t { step, linear, cubic_spline };
959enum class animation_target : uint8_t { translation, rotation, scale, weights, custom };
961struct animation_channel
963 uint64_t target_node_id{};
964 animation_target target_path{};
965 std::string custom_path;
967 animation_interpolation interpolation{animation_interpolation::linear};
969 std::shared_ptr<const std::vector<float>> times;
970 std::shared_ptr<const std::vector<float>> values;
973struct animation_component
975 ossia::small_vector<animation_channel, 16> channels;
977 float duration{0.0f};
980 int64_t dirty_index{};
982using animation_component_ptr = std::shared_ptr<const animation_component>;
985struct gaussian_splat_component
987 buffer_resource_ptr positions;
988 buffer_resource_ptr covariances;
989 buffer_resource_ptr sh_coefficients;
990 buffer_resource_ptr opacities;
992 uint32_t splat_count{};
993 uint8_t sh_degree{3};
996 buffer_resource_ptr cluster_bounds;
997 buffer_resource_ptr cluster_indices;
998 uint32_t cluster_count{};
999 float lod_bias{0.0f};
1002 float splat_scale{1.0f};
1005 int64_t dirty_index{};
1007using gaussian_splat_component_ptr = std::shared_ptr<const gaussian_splat_component>;
1010struct voxel_field_component
1012 buffer_resource_ptr morton_codes;
1013 buffer_resource_ptr densities;
1014 buffer_resource_ptr colors;
1015 buffer_resource_ptr emissions;
1017 uint32_t voxel_count{};
1018 uint32_t resolution[3]{256, 256, 256};
1020 float bounds_min[3]{};
1021 float bounds_max[3]{};
1023 float density_scale{1.0f};
1024 float step_size{0.01f};
1026 int64_t dirty_index{};
1028using voxel_field_component_ptr = std::shared_ptr<const voxel_field_component>;
1035struct primitive_cloud_component
1039 buffer_resource_ptr raw_data;
1043 uint32_t row_stride{};
1051 buffer_resource_ptr data;
1053 ossia::small_vector<named_buffer, 2> extra_buffers;
1055 uint64_t primitive_count{};
1056 primitive_topology topology{primitive_topology::points};
1060 std::string format_id;
1061 scene_property_map format_params;
1067 std::string struct_type_name;
1074 uint64_t stable_id{};
1076 int64_t dirty_index{};
1077 gpu_slot_ref raw_slot;
1079using primitive_cloud_component_ptr = std::shared_ptr<const primitive_cloud_component>;
1081struct point_cloud_component
1083 buffer_resource_ptr positions;
1084 buffer_resource_ptr colors;
1085 buffer_resource_ptr normals;
1086 buffer_resource_ptr intensities;
1088 uint64_t point_count{};
1091 buffer_resource_ptr hilbert_keys;
1092 buffer_resource_ptr range_bounds;
1093 uint32_t range_count{};
1096 float point_size{1.0f};
1097 enum class size_mode : uint8_t { fixed, adaptive } point_size_mode{};
1098 bool enable_edl{
true};
1100 int64_t dirty_index{};
1102using point_cloud_component_ptr = std::shared_ptr<const point_cloud_component>;
1104struct volume_channel
1106 buffer_resource_ptr data;
1107 enum class type : uint8_t { scalar_float, vector_float, scalar_half } data_type{};
1110struct volume_component
1112 ossia::small_vector<volume_channel, 4> channels;
1113 buffer_resource_ptr active_voxel_indices;
1115 uint32_t resolution[3]{};
1116 float voxel_size{0.1f};
1117 float bounds_min[3]{};
1118 float bounds_max[3]{};
1120 int64_t dirty_index{};
1122using volume_component_ptr = std::shared_ptr<const volume_component>;
1124struct instance_component
1126 mesh_component_ptr prototype;
1129 buffer_resource_ptr instance_transforms;
1130 buffer_resource_ptr instance_colors;
1131 buffer_resource_ptr instance_custom;
1133 uint32_t instance_count{};
1135 enum class transform_format : uint8_t
1140 } transform_type{transform_format::mat4};
1142 int64_t dirty_index{};
1144 gpu_slot_ref raw_slot;
1146using instance_component_ptr = std::shared_ptr<const instance_component>;
1150 buffer_resource_ptr data;
1151 int64_t dirty_index{};
1153using scene_data_ptr = std::shared_ptr<const scene_data>;
1156using scene_node_ptr = std::shared_ptr<const scene_node>;
1158using scene_payload = ossia::variant<
1161 material_component_ptr,
1162 light_component_ptr,
1163 camera_component_ptr,
1164 skeleton_component_ptr,
1165 animation_component_ptr,
1166 instance_component_ptr,
1168 gaussian_splat_component_ptr,
1169 voxel_field_component_ptr,
1170 point_cloud_component_ptr,
1171 volume_component_ptr,
1172 primitive_cloud_component_ptr,
1175enum class scene_purpose : uint8_t
1189 scene_purpose purpose{scene_purpose::default_};
1190 std::shared_ptr<const std::vector<scene_payload>> children;
1192 scene_property_map properties;
1194 int64_t dirty_index{};
1196 bool has_children() const noexcept {
return children && !children->empty(); }
1198 template <
typename T>
1199 const T* get_component() const noexcept;
1200 template <typename T>
1201 bool is() const noexcept;
1203struct scene_environment
1205 std::shared_ptr<const texture_source> skybox_source;
1207 gpu_texture_handle skybox_texture;
1208 gpu_texture_handle irradiance_map;
1209 gpu_texture_handle prefiltered_map;
1210 gpu_texture_handle brdf_lut;
1212 uint32_t params_set{0};
1213 enum params_bits : uint32_t
1215 params_exposure_gamma = 1u << 0,
1216 params_ambient = 1u << 1,
1217 params_fog = 1u << 2,
1218 params_render_target_size = 1u << 3,
1221 float exposure{1.0f};
1225 bool enabled{
false};
1226 float color[3]{0.8f, 0.8f, 0.8f};
1227 float density{0.01f};
1230 enum class type : uint8_t { linear, exponential, exponential_squared } mode{};
1232 float ambient_color[3]{0.f, 0.f, 0.f};
1233 float ambient_intensity{1.0f};
1234 uint32_t render_target_size[2]{0, 0};
1235 gpu_slot_ref raw_slot;
1237struct shadow_cascades_info
1239 static constexpr uint32_t max_cascades = 8;
1240 float split_view_depths[max_cascades + 1]{};
1241 float light_view_proj[max_cascades][16]{};
1242 gpu_texture_handle shadow_map_array{};
1243 uint32_t cascade_count{0};
1244 float shadow_distance{100.f};
1245 float light_direction[3]{0.f, -1.f, 0.f};
1248 gpu_slot_ref light_slot{};
1251struct aux_inject_buffer
1254 void* native_handle{};
1255 int64_t byte_size{};
1257struct aux_inject_texture
1260 void* native_handle{};
1262struct scene_collection
1265 ossia::small_vector<std::string, 8> paths;
1266 ossia::small_vector<std::string, 4>
tags;
1268using scene_collection_ptr = std::shared_ptr<const scene_collection>;
1272 std::shared_ptr<const std::vector<scene_node_ptr>> roots;
1273 std::shared_ptr<const std::vector<material_component_ptr>> materials;
1274 std::shared_ptr<const std::vector<animation_component_ptr>> animations;
1275 std::shared_ptr<const std::vector<skeleton_component_ptr>> skeletons;
1276 std::shared_ptr<const std::vector<camera_component_ptr>> cameras;
1278 std::shared_ptr<const std::vector<scene_collection_ptr>> collections;
1280 scene_environment environment{};
1281 shadow_cascades_info shadow_cascades{};
1283 ossia::small_vector<aux_inject_buffer, 4> inject_buffers;
1284 ossia::small_vector<aux_inject_texture, 4> inject_textures;
1286 scene_node_id active_camera_id{};
1287 double time_seconds{0.0};
1289 int32_t active_variant_index{-1};
1290 ossia::small_vector<std::string, 0> variant_names;
1293 int64_t dirty_index{};
1296 uint64_t total_nodes{};
1297 uint64_t total_triangles{};
1298 uint64_t total_vertices{};
1299 uint64_t total_lights{};
1300 uint64_t total_materials{};
1303 bool empty() const noexcept {
return !roots || roots->empty(); }
1305using scene_state_ptr = std::shared_ptr<const scene_state>;
1310 scene_state_ptr state;
1314 ossia::small_vector<scene_node_id, 16> added_nodes;
1315 ossia::small_vector<scene_node_id, 16> removed_nodes;
1316 ossia::small_vector<scene_node_id, 16> modified_nodes;
1318 std::shared_ptr<const scene_delta> delta;
1320 explicit operator bool() const noexcept {
return state !=
nullptr; }
1321 bool operator==(
const scene_spec& rhs)
const noexcept {
return state == rhs.state; }
1322 bool operator<(
const scene_spec& rhs)
const noexcept {
return state < rhs.state; }
1325struct OSSIA_EXPORT scene_port
1327 static const constexpr int which = 4;
1329 enum dirt_flags : uint8_t
1331 dirty_transform = 0x01,
1332 dirty_geometry = 0x02,
1333 dirty_materials = 0x04,
1334 dirty_lights = 0x08,
1335 dirty_animation = 0x10,
1336 dirty_environment = 0x20,
1337 dirty_structure = 0x40,
1344 scene_transform transform{};
1348struct scene_delay_line
1350 std::vector<scene_spec> scenes;
1351 size_t max_frames{60};
1352 size_t write_index{0};
1354OSSIA_EXPORT scene_spec wrap_geometry_as_scene(
const geometry_spec& geom);
1355OSSIA_EXPORT geometry_spec extract_first_geometry(
const scene_spec& scene);
1356OSSIA_EXPORT scene_spec merge_scenes(std::span<const scene_spec> scenes);
OSSIA_INLINE constexpr auto min(const T a, const U b) noexcept -> typename std::conditional<(sizeof(T) > sizeof(U)), T, U >::type
min function tailored for values
Definition math.hpp:125
OSSIA_INLINE constexpr auto max(const T a, const U b) noexcept -> typename std::conditional<(sizeof(T) > sizeof(U)), T, U >::type
max function tailored for values
Definition math.hpp:96
std::vector< std::string > tags
Tags applied to a node: {"model", "interesting", ...}.
Definition node_attributes.hpp:71
Handle to a GPU buffer (vertex, index, uniform, storage)
Definition geometry_port.hpp:480
Handle to a GPU texture with sampler state.
Definition geometry_port.hpp:491