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{std::numeric_limits<float>::infinity()};
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;
782 float color_factor[3]{0.0f, 0.0f, 0.0f};
783 texture_ref color_texture;
784 float roughness_factor{0.0f};
785 texture_ref roughness_texture;
792 float thickness_min{100.0f};
793 float thickness_max{400.0f};
794 texture_ref thickness_texture;
798 float strength{0.0f};
799 float rotation{0.0f};
805 float color_factor[3]{1.0f, 1.0f, 1.0f};
807 texture_ref color_texture;
808 } diffuse_transmission{};
812 bool shadow_caster{
true};
813 bool shadow_receiver{
true};
814 bool reflection_caster{
true};
818 scene_property_map properties;
820 int64_t dirty_index{};
821 gpu_slot_ref raw_slot;
822 uint64_t stable_id{};
824using material_component_ptr = std::shared_ptr<const material_component>;
826enum class light_type : uint8_t
828 directional, point, spot,
829 rect_area, disk_area, sphere_area, cylinder_area,
833enum class light_decay : uint8_t
840struct light_component
842 light_type type{light_type::point};
843 light_decay decay{light_decay::quadratic};
845 float color[3]{1.0f, 1.0f, 1.0f};
846 float intensity{1.0f};
849 float inner_cone_angle{0.0f};
850 float outer_cone_angle{0.7853981f};
857 buffer_resource_ptr ies_profile;
858 std::shared_ptr<const texture_source> environment_texture;
863 float normal_bias{0.01f};
864 uint32_t map_resolution{1024};
865 float near_plane{0.1f};
866 float far_plane{100.0f};
869 int64_t dirty_index{};
870 gpu_slot_ref raw_slot;
871 uint64_t stable_id{};
873using light_component_ptr = std::shared_ptr<const light_component>;
875enum class camera_projection : uint8_t { perspective, orthographic, fulldome };
877struct camera_component
879 camera_projection projection{camera_projection::perspective};
881 float yfov{0.7853981f};
882 float aspect_ratio{1.0f};
891 float focal_length{50.0f};
892 float focus_distance{10.0f};
894 float horizontal_aperture{36.0f};
895 float vertical_aperture{24.0f};
898 bool enable_dof{
false};
900 int64_t dirty_index{};
901 gpu_slot_ref raw_slot;
902 uint64_t stable_id{};
904using camera_component_ptr = std::shared_ptr<const camera_component>;
906struct OSSIA_EXPORT scene_node_id
910 bool operator==(
const scene_node_id&)
const noexcept =
default;
911 bool operator<(
const scene_node_id& rhs)
const noexcept {
return value < rhs.value; }
913 static scene_node_id from_path(std::string_view path)
noexcept;
914 static scene_node_id from_parent(scene_node_id parent, std::string_view name)
noexcept;
920 int32_t parent_index{-1};
921 float inverse_bind_matrix[16]{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};
923 float translation[3]{0, 0, 0};
924 float rotation[4]{0, 0, 0, 1};
925 float scale[3]{1, 1, 1};
928enum class skinning_method : uint8_t
934struct skeleton_component
936 ossia::small_vector<skeleton_joint, 64> joints;
937 buffer_resource_ptr joint_matrices_buffer;
939 ossia::small_vector<scene_node_id, 64> joint_node_ids;
941 skinning_method method{skinning_method::linear_blend};
943 int64_t dirty_index{};
945 int32_t find_joint(std::string_view name)
const noexcept
947 for(int32_t i = 0; i < (int32_t)joints.size(); i++)
948 if(joints[i].name == name)
953using skeleton_component_ptr = std::shared_ptr<const skeleton_component>;
955enum class animation_interpolation : uint8_t { step, linear, cubic_spline };
956enum class animation_target : uint8_t { translation, rotation, scale, weights, custom };
958struct animation_channel
960 uint64_t target_node_id{};
961 animation_target target_path{};
962 std::string custom_path;
964 animation_interpolation interpolation{animation_interpolation::linear};
966 std::shared_ptr<const std::vector<float>> times;
967 std::shared_ptr<const std::vector<float>> values;
970struct animation_component
972 ossia::small_vector<animation_channel, 16> channels;
974 float duration{0.0f};
977 int64_t dirty_index{};
979using animation_component_ptr = std::shared_ptr<const animation_component>;
982struct gaussian_splat_component
984 buffer_resource_ptr positions;
985 buffer_resource_ptr covariances;
986 buffer_resource_ptr sh_coefficients;
987 buffer_resource_ptr opacities;
989 uint32_t splat_count{};
990 uint8_t sh_degree{3};
993 buffer_resource_ptr cluster_bounds;
994 buffer_resource_ptr cluster_indices;
995 uint32_t cluster_count{};
996 float lod_bias{0.0f};
999 float splat_scale{1.0f};
1002 int64_t dirty_index{};
1004using gaussian_splat_component_ptr = std::shared_ptr<const gaussian_splat_component>;
1007struct voxel_field_component
1009 buffer_resource_ptr morton_codes;
1010 buffer_resource_ptr densities;
1011 buffer_resource_ptr colors;
1012 buffer_resource_ptr emissions;
1014 uint32_t voxel_count{};
1015 uint32_t resolution[3]{256, 256, 256};
1017 float bounds_min[3]{};
1018 float bounds_max[3]{};
1020 float density_scale{1.0f};
1021 float step_size{0.01f};
1023 int64_t dirty_index{};
1025using voxel_field_component_ptr = std::shared_ptr<const voxel_field_component>;
1032struct primitive_cloud_component
1036 buffer_resource_ptr raw_data;
1040 uint32_t row_stride{};
1048 buffer_resource_ptr data;
1050 ossia::small_vector<named_buffer, 2> extra_buffers;
1052 uint64_t primitive_count{};
1053 primitive_topology topology{primitive_topology::points};
1057 std::string format_id;
1058 scene_property_map format_params;
1064 std::string struct_type_name;
1071 uint64_t stable_id{};
1073 int64_t dirty_index{};
1074 gpu_slot_ref raw_slot;
1076using primitive_cloud_component_ptr = std::shared_ptr<const primitive_cloud_component>;
1078struct point_cloud_component
1080 buffer_resource_ptr positions;
1081 buffer_resource_ptr colors;
1082 buffer_resource_ptr normals;
1083 buffer_resource_ptr intensities;
1085 uint64_t point_count{};
1088 buffer_resource_ptr hilbert_keys;
1089 buffer_resource_ptr range_bounds;
1090 uint32_t range_count{};
1093 float point_size{1.0f};
1094 enum class size_mode : uint8_t { fixed, adaptive } point_size_mode{};
1095 bool enable_edl{
true};
1097 int64_t dirty_index{};
1099using point_cloud_component_ptr = std::shared_ptr<const point_cloud_component>;
1101struct volume_channel
1103 buffer_resource_ptr data;
1104 enum class type : uint8_t { scalar_float, vector_float, scalar_half } data_type{};
1107struct volume_component
1109 ossia::small_vector<volume_channel, 4> channels;
1110 buffer_resource_ptr active_voxel_indices;
1112 uint32_t resolution[3]{};
1113 float voxel_size{0.1f};
1114 float bounds_min[3]{};
1115 float bounds_max[3]{};
1117 int64_t dirty_index{};
1119using volume_component_ptr = std::shared_ptr<const volume_component>;
1121struct instance_component
1123 mesh_component_ptr prototype;
1126 buffer_resource_ptr instance_transforms;
1127 buffer_resource_ptr instance_colors;
1128 buffer_resource_ptr instance_custom;
1130 uint32_t instance_count{};
1132 enum class transform_format : uint8_t
1137 } transform_type{transform_format::mat4};
1139 int64_t dirty_index{};
1141 gpu_slot_ref raw_slot;
1143using instance_component_ptr = std::shared_ptr<const instance_component>;
1147 buffer_resource_ptr data;
1148 int64_t dirty_index{};
1150using scene_data_ptr = std::shared_ptr<const scene_data>;
1153using scene_node_ptr = std::shared_ptr<const scene_node>;
1155using scene_payload = ossia::variant<
1158 material_component_ptr,
1159 light_component_ptr,
1160 camera_component_ptr,
1161 skeleton_component_ptr,
1162 animation_component_ptr,
1163 instance_component_ptr,
1165 gaussian_splat_component_ptr,
1166 voxel_field_component_ptr,
1167 point_cloud_component_ptr,
1168 volume_component_ptr,
1169 primitive_cloud_component_ptr,
1172enum class scene_purpose : uint8_t
1186 scene_purpose purpose{scene_purpose::default_};
1187 std::shared_ptr<const std::vector<scene_payload>> children;
1189 scene_property_map properties;
1191 int64_t dirty_index{};
1193 bool has_children() const noexcept {
return children && !children->empty(); }
1195 template <
typename T>
1196 const T* get_component() const noexcept;
1197 template <typename T>
1198 bool is() const noexcept;
1200struct scene_environment
1202 std::shared_ptr<const texture_source> skybox_source;
1204 gpu_texture_handle skybox_texture;
1205 gpu_texture_handle irradiance_map;
1206 gpu_texture_handle prefiltered_map;
1207 gpu_texture_handle brdf_lut;
1209 uint32_t params_set{0};
1210 enum params_bits : uint32_t
1212 params_exposure_gamma = 1u << 0,
1213 params_ambient = 1u << 1,
1214 params_fog = 1u << 2,
1215 params_render_target_size = 1u << 3,
1218 float exposure{1.0f};
1222 bool enabled{
false};
1223 float color[3]{0.8f, 0.8f, 0.8f};
1224 float density{0.01f};
1227 enum class type : uint8_t { linear, exponential, exponential_squared } mode{};
1229 float ambient_color[3]{0.03f, 0.03f, 0.03f};
1230 float ambient_intensity{1.0f};
1231 uint32_t render_target_size[2]{0, 0};
1232 gpu_slot_ref raw_slot;
1234struct shadow_cascades_info
1236 static constexpr uint32_t max_cascades = 8;
1237 float split_view_depths[max_cascades + 1]{};
1238 float light_view_proj[max_cascades][16]{};
1239 gpu_texture_handle shadow_map_array{};
1240 uint32_t cascade_count{0};
1241 float shadow_distance{100.f};
1242 float light_direction[3]{0.f, -1.f, 0.f};
1245struct aux_inject_buffer
1248 void* native_handle{};
1249 int64_t byte_size{};
1251struct aux_inject_texture
1254 void* native_handle{};
1256struct scene_collection
1259 ossia::small_vector<std::string, 8> paths;
1260 ossia::small_vector<std::string, 4>
tags;
1262using scene_collection_ptr = std::shared_ptr<const scene_collection>;
1266 std::shared_ptr<const std::vector<scene_node_ptr>> roots;
1267 std::shared_ptr<const std::vector<material_component_ptr>> materials;
1268 std::shared_ptr<const std::vector<animation_component_ptr>> animations;
1269 std::shared_ptr<const std::vector<skeleton_component_ptr>> skeletons;
1270 std::shared_ptr<const std::vector<camera_component_ptr>> cameras;
1272 std::shared_ptr<const std::vector<scene_collection_ptr>> collections;
1274 scene_environment environment{};
1275 shadow_cascades_info shadow_cascades{};
1277 ossia::small_vector<aux_inject_buffer, 4> inject_buffers;
1278 ossia::small_vector<aux_inject_texture, 4> inject_textures;
1280 scene_node_id active_camera_id{};
1281 double time_seconds{0.0};
1283 int32_t active_variant_index{-1};
1284 ossia::small_vector<std::string, 0> variant_names;
1287 int64_t dirty_index{};
1290 uint64_t total_nodes{};
1291 uint64_t total_triangles{};
1292 uint64_t total_vertices{};
1293 uint64_t total_lights{};
1294 uint64_t total_materials{};
1297 bool empty() const noexcept {
return !roots || roots->empty(); }
1299using scene_state_ptr = std::shared_ptr<const scene_state>;
1304 scene_state_ptr state;
1308 ossia::small_vector<scene_node_id, 16> added_nodes;
1309 ossia::small_vector<scene_node_id, 16> removed_nodes;
1310 ossia::small_vector<scene_node_id, 16> modified_nodes;
1312 std::shared_ptr<const scene_delta> delta;
1314 explicit operator bool() const noexcept {
return state !=
nullptr; }
1315 bool operator==(
const scene_spec& rhs)
const noexcept {
return state == rhs.state; }
1316 bool operator<(
const scene_spec& rhs)
const noexcept {
return state < rhs.state; }
1319struct OSSIA_EXPORT scene_port
1321 static const constexpr int which = 4;
1323 enum dirt_flags : uint8_t
1325 dirty_transform = 0x01,
1326 dirty_geometry = 0x02,
1327 dirty_materials = 0x04,
1328 dirty_lights = 0x08,
1329 dirty_animation = 0x10,
1330 dirty_environment = 0x20,
1331 dirty_structure = 0x40,
1338 scene_transform transform{};
1342struct scene_delay_line
1344 std::vector<scene_spec> scenes;
1345 size_t max_frames{60};
1346 size_t write_index{0};
1348OSSIA_EXPORT scene_spec wrap_geometry_as_scene(
const geometry_spec& geom);
1349OSSIA_EXPORT geometry_spec extract_first_geometry(
const scene_spec& scene);
1350OSSIA_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