Blender V5.3
scene/object.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#include "scene/object.h"
6
7#include "device/device.h"
8#include "kernel/types.h"
9#include "scene/camera.h"
10#include "scene/curves.h"
11#include "scene/hair.h"
12#include "scene/integrator.h"
13#include "scene/light.h"
14#include "scene/mesh.h"
15#include "scene/particles.h"
16#include "scene/pointcloud.h"
17#include "scene/scene.h"
18#include "scene/shader.h"
19#include "scene/stats.h"
20#include "scene/volume.h"
21
22#include "util/hash.h"
23#include "util/log.h"
24#include "util/map.h"
25#include "util/murmurhash.h"
26#include "util/progress.h"
27#include "util/set.h"
28#include "util/tbb.h"
29#include "util/vector.h"
30
32
34
35/* Global state of object transform update. */
36
38 /* Global state used by device_update_object_transform().
39 * Common for both threaded and non-threaded update.
40 */
41
42 /* Type of the motion required by the scene settings. */
44
45 /* Mapping from particle system to a index in packed particle array.
46 * Only used for read.
47 */
48 map<ParticleSystem *, int> particle_offset;
49
50 /* Motion offsets for each object. */
52
53 /* Packed object arrays. Those will be filled in. */
59
60 /* Flags which will be synchronized to Integrator. */
65
66 /* ** Scheduling queue. ** */
68
69 /* First unused object index in the queue. */
71};
72
73/* Object */
74
76{
77 NodeType *type = NodeType::add("object", create);
78
79 SOCKET_NODE(geometry, "Geometry", Geometry::get_node_base_type());
80 SOCKET_TRANSFORM(tfm, "Transform", transform_identity());
81 SOCKET_UINT(visibility, "Visibility", PATH_RAY_VISIBILITY_OBJECT_ALL);
82 SOCKET_COLOR(color, "Color", zero_float3());
83 SOCKET_FLOAT(alpha, "Alpha", 0.0f);
84 SOCKET_UINT(random_id, "Random ID", 0);
85 SOCKET_INT(pass_id, "Pass ID", 0);
86 SOCKET_BOOLEAN(use_holdout, "Use Holdout", false);
87 SOCKET_BOOLEAN(hide_on_missing_motion, "Hide on Missing Motion", false);
88 SOCKET_POINT(dupli_generated, "Dupli Generated", zero_float3());
89 SOCKET_POINT2(dupli_uv, "Dupli UV", zero_float2());
90 SOCKET_TRANSFORM_ARRAY(motion, "Motion", array<Transform>());
91 SOCKET_FLOAT(shadow_terminator_shading_offset, "Shadow Terminator Shading Offset", 0.0f);
92 SOCKET_FLOAT(shadow_terminator_geometry_offset, "Shadow Terminator Geometry Offset", 0.1f);
93 SOCKET_STRING(asset_name, "Asset Name", ustring());
94
95 SOCKET_BOOLEAN(is_shadow_catcher, "Shadow Catcher", false);
96
97 SOCKET_BOOLEAN(is_caustics_caster, "Cast Shadow Caustics", false);
98 SOCKET_BOOLEAN(is_caustics_receiver, "Receive Shadow Caustics", false);
99
100 SOCKET_BOOLEAN(is_bake_target, "Bake Target", false);
101
102 SOCKET_NODE(particle_system, "Particle System", ParticleSystem::get_node_type());
103 SOCKET_INT(particle_index, "Particle Index", 0);
104
105 SOCKET_FLOAT(ao_distance, "AO Distance", 0.0f);
106
107 SOCKET_STRING(lightgroup, "Light Group", ustring());
108 SOCKET_UINT(receiver_light_set, "Light Set Index", 0);
109 SOCKET_UINT64(light_set_membership, "Light Set Membership", LIGHT_LINK_MASK_ALL);
110 SOCKET_UINT(blocker_shadow_set, "Shadow Set Index", 0);
111 SOCKET_UINT64(shadow_set_membership, "Shadow Set Membership", LIGHT_LINK_MASK_ALL);
112
113 return type;
114}
115
116Object::Object() : Node(get_node_type())
117{
118 particle_system = nullptr;
119 particle_index = 0;
120 attr_map_offset = 0;
122 intersects_volume = false;
123}
124
125Object::~Object() = default;
126
128{
129 if (!use_motion()) {
130 return;
131 }
132
133 bool have_motion = false;
134
135 for (size_t i = 0; i < motion.size(); i++) {
136 if (motion[i] == transform_empty()) {
137 /* Motion passes enabled for interactive denoising should not cause
138 * objects in the current frame to become hidden. */
139 if (hide_on_missing_motion && need_motion != Scene::MOTION_PASS_INTERACTIVE) {
140 /* Hide objects that have no valid previous or next
141 * transform, for example particle that stop existing. It
142 * would be better to handle this in the kernel and make
143 * objects invisible outside certain motion steps. */
144 tfm = transform_empty();
145 motion.clear();
146 return;
147 }
148
149 if (have_motion && i == (motion.size() - 1)) {
150 /* Remove last motion when it is not actually set. */
151 motion.resize(motion.size() - 1);
152 return;
153 }
154
155 /* Otherwise just copy center motion. */
156 motion[i] = tfm;
157 }
158
159 /* Test if any of the transforms are actually different. */
160 have_motion = have_motion || motion[i] != tfm;
161 }
162
163 /* Clear motion array if there is no actual motion. */
164 if (!have_motion) {
165 motion.clear();
166 }
167}
168
169void Object::compute_bounds(bool motion_blur)
170{
171 const BoundBox mbounds = geometry->bounds;
172
173 if (motion_blur && use_motion()) {
174 array<DecomposedTransform> decomp(motion.size());
175 transform_motion_decompose(decomp.data(), motion.data(), motion.size());
176
178
179 /* TODO: this is really terrible. according to PBRT there is a better
180 * way to find this iteratively, but did not find implementation yet
181 * or try to implement myself */
182 for (float t = 0.0f; t < 1.0f; t += (1.0f / 128.0f)) {
183 Transform ttfm;
184
185 transform_motion_array_interpolate(&ttfm, decomp.data(), motion.size(), t);
186 bounds.grow(mbounds.transformed(&ttfm));
187 }
188 }
189 else {
190 /* No motion blur case. */
191 if (geometry->transform_applied) {
192 bounds = mbounds;
193 }
194 else {
195 bounds = mbounds.transformed(&tfm);
196 }
197 }
198}
199
200void Object::apply_transform(bool apply_to_motion)
201{
202 if (!geometry || tfm == transform_identity()) {
203 return;
204 }
205
206 geometry->apply_transform(tfm, apply_to_motion);
207
208 /* we keep normals pointing in same direction on negative scale, notify
209 * geometry about this in it (re)calculates normals */
210 if (transform_negative_scale(tfm)) {
211 geometry->transform_negative_scaled = true;
212 }
213
214 if (bounds.valid()) {
215 geometry->compute_bounds();
216 compute_bounds(false);
217 }
218
219 /* tfm is not reset to identity, all code that uses it needs to check the
220 * transform_applied boolean */
221}
222
224{
225 uint32_t flag = ObjectManager::UPDATE_NONE;
226
227 if (is_modified()) {
229
230 if (use_holdout_is_modified()) {
232 }
233
234 if (is_shadow_catcher_is_modified()) {
237 }
238 }
239
240 if (geometry) {
241 if (tfm_is_modified() || motion_is_modified()) {
243 if (geometry->has_volume) {
244 scene->volume_manager->tag_update({this}, flag);
245 }
246 }
247
248 if (visibility_is_modified()) {
250 }
251
252 for (Node *node : geometry->get_used_shaders()) {
253 Shader *shader = static_cast<Shader *>(node);
255 scene->light_manager->tag_update(scene, LightManager::EMISSIVE_MESH_MODIFIED);
256 }
257 }
258 }
259
260 scene->camera->need_flags_update = true;
261 scene->object_manager->tag_update(scene, flag);
262}
263
265{
266 return (motion.size() > 1);
267}
268
269float Object::motion_time(const int step) const
270{
271 return (use_motion()) ? 2.0f * step / (motion.size() - 1) - 1.0f : 0.0f;
272}
273
274int Object::motion_step(const float time) const
275{
276 if (use_motion()) {
277 for (size_t step = 0; step < motion.size(); step++) {
278 if (time == motion_time(step)) {
279 return step;
280 }
281 }
282 }
283
284 return -1;
285}
286
288{
289 /* Not supported for lights yet. */
290 if (geometry->is_light()) {
291 return false;
292 }
293 /* Mesh itself can be empty,can skip all such objects. */
294 if (!bounds.valid() || bounds.size() == zero_float3()) {
295 return false;
296 }
297 /* TODO(sergey): Check for mesh vertices/curves. visibility flags. */
298 return true;
299}
300
302{
303 assert((visibility & ~uint(PATH_RAY_VISIBILITY_OBJECT_ALL)) == 0);
304 return SHADOW_CATCHER_OBJECT_VISIBILITY(is_shadow_catcher, visibility);
305}
306
308{
309 if (geometry->is_light()) {
310 /* World volume. */
311 assert(static_cast<const Light *>(geometry)->is_background_light());
312 for (const Node *node : geometry->get_used_shaders()) {
313 const Shader *shader = static_cast<const Shader *>(node);
314 if (shader->has_volume) {
315 return shader->get_volume_step_rate();
316 }
317 }
318 assert(false);
319 return FLT_MAX;
320 }
321
322 if (!geometry->is_mesh() && !geometry->is_volume()) {
323 return FLT_MAX;
324 }
325
326 Mesh *mesh = static_cast<Mesh *>(geometry);
327
328 if (!mesh->has_volume) {
329 return FLT_MAX;
330 }
331
332 /* Compute step rate from shaders. */
333 float step_rate = FLT_MAX;
334
335 for (Node *node : mesh->get_used_shaders()) {
336 Shader *shader = static_cast<Shader *>(node);
337 if (shader->has_volume) {
339 step_rate = fminf(shader->get_volume_step_rate(), step_rate);
340 }
341 }
342 }
343
344 if (step_rate == FLT_MAX) {
345 return FLT_MAX;
346 }
347
348 /* Compute step size from voxel grids. */
349 float step_size = FLT_MAX;
350
351 if (geometry->is_volume()) {
352 Volume *volume = static_cast<Volume *>(geometry);
353
354 for (Attribute &attr : volume->attributes.attributes) {
355 if (attr.element == ATTR_ELEMENT_VOXEL) {
356 ImageHandle &handle = attr.data_voxel_for_write();
357 const ImageMetaData &metadata = handle.metadata(progress);
358 if (metadata.nanovdb_byte_size == 0) {
359 continue;
360 }
361
362 /* User specified step size. */
363 float voxel_step_size = volume->get_step_size();
364
365 if (voxel_step_size == 0.0f) {
366 /* Auto detect step size.
367 * Step size is transformed from voxel to world space. */
368 Transform voxel_tfm = tfm;
369 if (metadata.use_transform_3d) {
370 voxel_tfm = tfm * transform_inverse(metadata.transform_3d);
371 }
372 voxel_step_size = reduce_min(fabs(transform_direction(&voxel_tfm, one_float3())));
373 }
374 else if (volume->get_object_space()) {
375 /* User specified step size in object space. */
376 const float3 size = make_float3(voxel_step_size, voxel_step_size, voxel_step_size);
377 voxel_step_size = reduce_min(fabs(transform_direction(&tfm, size)));
378 }
379
380 if (voxel_step_size > 0.0f) {
381 step_size = fminf(voxel_step_size, step_size);
382 }
383 }
384 }
385 }
386
387 if (step_size == FLT_MAX) {
388 /* Fall back to 1/10th of bounds for procedural volumes. */
390 step_size = 0.1f * average(bounds.size());
391 }
392
393 step_size *= step_rate;
394
395 return step_size;
396}
397
399{
400 return index;
401}
402
404{
405 Geometry *geom = get_geometry();
406 if (!geom->is_mesh() && !geom->is_volume()) {
407 return false;
408 }
409 /* Skip non-traceable objects. */
410 if (!is_traceable()) {
411 return false;
412 }
413 /* Skip if we are not visible for BSDFs. */
414 if (!(get_visibility() & (PATH_RAY_VISIBILITY_DIFFUSE | PATH_RAY_VISIBILITY_GLOSSY |
416 {
417 return false;
418 }
419 /* Skip if we have no emission shaders. */
420 /* TODO(sergey): Ideally we want to avoid such duplicated loop, since it'll
421 * iterate all geometry shaders twice (when counting and when calculating
422 * triangle area.
423 */
424 for (Node *node : geom->get_used_shaders()) {
425 Shader *shader = static_cast<Shader *>(node);
427 return true;
428 }
429 }
430 return false;
431}
432
434{
435 if (get_receiver_light_set()) {
436 return true;
437 }
438
439 if (get_light_set_membership() != LIGHT_LINK_MASK_ALL) {
440 return true;
441 }
442
443 return false;
444}
445
447{
448 if (get_blocker_shadow_set()) {
449 return true;
450 }
451
452 if (get_shadow_set_membership() != LIGHT_LINK_MASK_ALL) {
453 return true;
454 }
455
456 return false;
457}
458
460{
461 if (geometry) {
462 if (geometry->is_volume()) {
463 /* Slightly offset vertex coordinates to avoid overlapping faces with other volumes or
464 * meshes. The proper solution would be to improve intersection in the kernel to support
465 * robust handling of multiple overlapping faces or use an all-hit intersection similar to
466 * shadows. */
467 const uint name_hash = hash_string(name.c_str());
468 const float3 offset = transform_direction(&tfm,
469 make_float3(hash_uint2_to_float(name_hash, 0),
470 hash_uint2_to_float(name_hash, 1),
471 hash_uint2_to_float(name_hash, 2)) *
472 0.001f);
473 transform_translate(tfm, offset);
474 }
475 }
476}
477
479{
481 const SocketType *socket = get_tfm_socket();
482 set(*socket, tfm);
483}
484
486{
488 return tfm == get_tfm();
489}
490
491void Object::set_motion_tfm(Transform tfm, const int step_index)
492{
494 array<Transform> motion = get_motion();
495 motion[step_index] = tfm;
496 set_motion(motion);
497}
498
499/* Object Manager */
500
502{
503 update_flags = UPDATE_ALL;
504 need_flags_update = true;
505}
506
508
510{
511 bool update = false;
512
513 parallel_for(blocked_range<size_t>(0, scene->objects.size(), 32),
514 [&](const blocked_range<size_t> &r) {
515 for (size_t i = r.begin(); i != r.end(); i++) {
516 Object *ob = scene->objects[i];
517
518 const bool use_motion = ob->use_motion();
519
520 array<Transform> motion = ob->get_motion();
521 if (motion.empty()) {
522 /* Can always store current matrix in motion array with a single element,
523 * since that still causes 'use_motion()' to return false. */
524 motion.resize(1);
525 }
526 motion[0] = ob->tfm;
527
528 /* Trigger another update if there was motion compared to previous frame, so
529 * that last movement does not stick around. */
530 ob->set_motion(motion);
531
532 if (use_motion && ob->motion_is_modified()) {
533 update = true;
534 }
535 }
536 });
537
538 if (update) {
539 tag_update(scene, TRANSFORM_MODIFIED);
540 }
541}
542
543static float object_volume_density(const Transform &tfm, Geometry *geom)
544{
545 if (geom->is_volume()) {
546 /* Volume density automatically adjust to object scale. */
547 if (static_cast<Volume *>(geom)->get_object_space()) {
548 const float3 unit = normalize(one_float3());
549 return 1.0f / len(transform_direction(&tfm, unit));
550 }
551 }
552
553 return 1.0f;
554}
555
557{
558 return (geom->is_mesh() || geom->is_volume()) ? static_cast<Mesh *>(geom)->num_verts() :
559 geom->is_hair() ? static_cast<Hair *>(geom)->num_keys() :
560 geom->is_pointcloud() ? static_cast<PointCloud *>(geom)->num_points() :
561 0;
562}
563
565 Object *ob,
566 bool update_all,
567 const Scene *scene)
568{
569 KernelObject &kobject = state->objects[ob->index];
570 Transform *object_motion_pass = state->object_motion_pass;
571
572 Geometry *geom = ob->geometry;
573 uint flag = 0;
574
575 /* Compute transformations. */
576 const Transform tfm = ob->tfm;
577 const Transform itfm = transform_inverse(tfm);
578
579 const float3 color = ob->color;
580 const float pass_id = ob->pass_id;
581 const float random_number = (float)ob->random_id * (1.0f / (float)0xFFFFFFFF);
582 const int particle_index = (ob->particle_system) ?
583 ob->particle_index + state->particle_offset[ob->particle_system] :
584 0;
585
586 kobject.tfm = tfm;
587 kobject.itfm = itfm;
588 kobject.color[0] = color.x;
589 kobject.color[1] = color.y;
590 kobject.color[2] = color.z;
591 kobject.alpha = ob->alpha;
592 kobject.pass_id = pass_id;
593 kobject.random_number = random_number;
595 kobject.motion_offset = 0;
597 kobject.ao_distance = ob->ao_distance;
598 kobject.receiver_light_set = ob->receiver_light_set >= LIGHT_LINK_SET_MAX ?
599 0 :
600 ob->receiver_light_set;
601 kobject.light_set_membership = ob->light_set_membership;
602 kobject.blocker_shadow_set = ob->blocker_shadow_set >= LIGHT_LINK_SET_MAX ?
603 0 :
604 ob->blocker_shadow_set;
605 kobject.shadow_set_membership = ob->shadow_set_membership;
606
607 if (geom->get_use_motion_blur()) {
608 state->have_motion = true;
609 }
610
611 if (transform_negative_scale(tfm)) {
613 }
614
615 if (geom->is_hair()) {
616 const Attribute *attr_P = geom->attributes.find(ATTR_STD_POSITION);
617 if (attr_P->has_motion()) {
619 }
620 }
621 else if (geom->is_pointcloud()) {
622 const PointCloud *pointcloud = static_cast<PointCloud *>(geom);
623 if (pointcloud->primitive_type() & PRIMITIVE_GSPLAT) {
624 /* NOTE: scale, rotation, and radiance base attributes are required.
625 * The value here does not really matter as it'll be overwritten by a proper offset. Keep the
626 * initialization to allow catching logical errors with asserts. */
627 kobject.gsplat.scale_offset_and_flag = ATTR_STD_NOT_FOUND;
628 kobject.gsplat.rotation_offset_and_flag = ATTR_STD_NOT_FOUND;
629 kobject.gsplat.radiance_base_offset_and_flag = ATTR_STD_NOT_FOUND;
630
631 kobject.gsplat.radiance_spherical_harmonics_rest_offset = ATTR_STD_NOT_FOUND;
632 }
633 const Attribute *attr_P = geom->attributes.find(ATTR_STD_POSITION);
634 if (attr_P->has_motion()) {
636 }
637 }
638 else if (geom->is_volume()) {
639 Volume *volume = static_cast<Volume *>(geom);
640 if (volume->attributes.find(ATTR_STD_VOLUME_VELOCITY) && volume->get_velocity_scale() != 0.0f)
641 {
643 kobject.mesh_volume.volume_velocity_scale = volume->get_velocity_scale();
644 }
645 }
646 else if (geom->is_mesh()) {
647 Mesh *mesh = static_cast<Mesh *>(geom);
648 const Attribute *attr_P = mesh->attributes.find(ATTR_STD_POSITION);
649 const Attribute *subd_attr_P = (mesh->get_subdivision_type() != Mesh::SUBDIVISION_NONE) ?
651 nullptr;
652 if (attr_P->has_motion() || (subd_attr_P && subd_attr_P->has_motion())) {
654 }
655 else if (mesh->attributes.find(ATTR_STD_CORNER_NORMAL)) {
657 }
658 }
659
660 if (state->need_motion == Scene::MOTION_PASS ||
662 {
663 /* Clear motion array if there is no actual motion. */
664 ob->update_motion(state->need_motion);
665
666 /* Compute motion transforms. */
667 Transform tfm_pre;
668 Transform tfm_post;
669 if (ob->use_motion()) {
670 tfm_pre = ob->motion[0];
671 tfm_post = ob->motion[ob->motion.size() - 1];
672 }
673 else {
674 tfm_pre = tfm;
675 tfm_post = tfm;
676 }
677
678 /* Motion transformations, is world/object space depending if mesh
679 * comes with deformed position in object space, or if we transform
680 * the shading point in world space. */
681 if (!(flag & SD_OBJECT_HAS_VERTEX_MOTION)) {
682 if (ob->use_motion()) {
683 tfm_pre = tfm_pre * itfm;
684 tfm_post = tfm_post * itfm;
685 }
686 else {
687 /* Use identity to avoid numerical inaccuracy of tfm * transform_inverse(tfm). */
688 tfm_pre = transform_identity();
689 tfm_post = transform_identity();
690 }
691 }
692
693 const int motion_pass_offset = ob->index * OBJECT_MOTION_PASS_SIZE;
694 object_motion_pass[motion_pass_offset + 0] = tfm_pre;
695 object_motion_pass[motion_pass_offset + 1] = tfm_post;
696 }
697 else if (state->need_motion == Scene::MOTION_BLUR) {
698 if (ob->use_motion()) {
699 kobject.motion_offset = state->motion_offset[ob->index];
700
701 /* Decompose transforms for interpolation. */
702 if (ob->tfm_is_modified() || ob->motion_is_modified() || update_all) {
703 DecomposedTransform *decomp = state->object_motion + kobject.motion_offset;
704 transform_motion_decompose(decomp, ob->motion.data(), ob->motion.size());
705 }
706
707 flag |= SD_OBJECT_MOTION;
708 state->have_motion = true;
709 }
710 }
711
712 /* Dupli object coords and motion info. */
713 kobject.dupli_generated[0] = ob->dupli_generated[0];
714 kobject.dupli_generated[1] = ob->dupli_generated[1];
715 kobject.dupli_generated[2] = ob->dupli_generated[2];
716 kobject.dupli_uv[0] = ob->dupli_uv[0];
717 kobject.dupli_uv[1] = ob->dupli_uv[1];
718 kobject.num_geom_steps = geom->get_motion_steps();
719 kobject.num_tfm_steps = ob->motion.size();
720 kobject.numverts = object_num_motion_verts(geom);
721 if (geom->is_mesh() || geom->is_volume()) {
722 kobject.mesh_volume.volume_density = object_volume_density(tfm, geom);
723 kobject.mesh_volume.num_prims = static_cast<Mesh *>(geom)->num_triangles();
724 kobject.mesh_volume.normal_offset = ATTR_STD_NOT_FOUND;
725 }
726 kobject.attribute_map_offset = 0;
727
728 if (ob->asset_name_is_modified() || update_all) {
729 const uint32_t hash_name = util_murmur_hash3(ob->name.c_str(), ob->name.length(), 0);
730 const uint32_t hash_asset = util_murmur_hash3(
731 ob->asset_name.c_str(), ob->asset_name.length(), 0);
732 kobject.cryptomatte_object = util_hash_to_float(hash_name);
733 kobject.cryptomatte_asset = util_hash_to_float(hash_asset);
734 }
735
736 kobject.shadow_terminator_shading_offset = 1.0f /
737 (1.0f - 0.5f * ob->shadow_terminator_shading_offset);
738 kobject.shadow_terminator_geometry_offset = ob->shadow_terminator_geometry_offset;
739
740 kobject.visibility = ob->visibility_for_tracing();
741 kobject.primitive_type = geom->primitive_type();
742
743 /* Object shadow caustics flag */
744 if (ob->is_caustics_caster) {
746 }
747 if (ob->is_caustics_receiver) {
749 }
750
751 /* Object flag. */
752 if (ob->use_holdout) {
754 }
755 state->object_flag[ob->index] = flag;
756
757 /* Have curves. */
758 if (geom->is_hair()) {
759 state->have_curves = true;
760 }
761 if (geom->is_pointcloud()) {
762 state->have_points = true;
763 }
764 if (geom->is_volume()) {
765 state->have_volumes = true;
766 }
767
768 /* Light group. */
769 auto it = scene->lightgroups.find(ob->lightgroup);
770 if (it != scene->lightgroups.end()) {
771 kobject.lightgroup = it->second;
772 }
773 else {
774 kobject.lightgroup = LIGHTGROUP_NONE;
775 }
776}
777
779 DeviceScene *dscene,
780 Scene *scene)
781{
782 /* Currently only OptiX and BVH2 do not require object_prim_offset (unless light trees are used).
783 * While it is possible to save some computation time here and device memory, the logic for it
784 * becomes tricky and fragile. */
785#if 0
786 if (!scene->integrator->get_use_light_tree()) {
787 const BVHLayoutMask layout_mask = device->get_bvh_layout_mask(dscene->data.kernel_features);
788 if (layout_mask != BVH_LAYOUT_METAL && layout_mask != BVH_LAYOUT_MULTI_METAL &&
789 layout_mask != BVH_LAYOUT_MULTI_METAL_EMBREE && layout_mask != BVH_LAYOUT_HIPRT &&
790 layout_mask != BVH_LAYOUT_MULTI_HIPRT && layout_mask != BVH_LAYOUT_MULTI_HIPRT_EMBREE)
791 {
792 return;
793 }
794 }
795#endif
796
797 /* On MetalRT, primitive / curve segment offsets can't be baked at BVH build time. Intersection
798 * handlers need to apply the offset manually. */
799 uint *object_prim_offset = dscene->object_prim_offset.alloc(scene->objects.size());
800 for (Object *ob : scene->objects) {
801 uint32_t prim_offset = 0;
802 if (Geometry *const geom = ob->geometry) {
803 if (geom->is_hair()) {
804 prim_offset = ((Hair *)geom)->curve_segment_offset;
805 }
806 else {
807 prim_offset = geom->prim_offset;
808 }
809 }
810 const uint obj_index = ob->get_device_index();
811 object_prim_offset[obj_index] = prim_offset;
812 }
813
816}
817
819{
821 state.need_motion = scene->need_motion();
822 state.have_motion = false;
823 state.have_curves = false;
824 state.have_points = false;
825 state.have_volumes = false;
826 state.scene = scene;
827 state.queue_start_object = 0;
828
829 state.objects = dscene->objects.alloc(scene->objects.size());
830 state.object_flag = dscene->object_flag.alloc(scene->objects.size());
831 state.object_motion = nullptr;
832 state.object_motion_pass = nullptr;
833
834 if (state.need_motion == Scene::MOTION_PASS ||
836 {
837 state.object_motion_pass = dscene->object_motion_pass.alloc(OBJECT_MOTION_PASS_SIZE *
838 scene->objects.size());
839 }
840 else if (state.need_motion == Scene::MOTION_BLUR) {
841 /* Set object offsets into global object motion array. */
842 uint *motion_offsets = state.motion_offset.resize(scene->objects.size());
843 uint motion_offset = 0;
844
845 for (Object *ob : scene->objects) {
846 *motion_offsets = motion_offset;
847 motion_offsets++;
848
849 /* Clear motion array if there is no actual motion. */
850 ob->update_motion(state.need_motion);
851 motion_offset += ob->motion.size();
852 }
853
854 state.object_motion = dscene->object_motion.alloc(motion_offset);
855 }
856
857 /* Particle system device offsets
858 * 0 is dummy particle, index starts at 1.
859 */
860 int numparticles = 1;
861 for (ParticleSystem *psys : scene->particle_systems) {
862 state.particle_offset[psys] = numparticles;
863 numparticles += psys->particles.size();
864 }
865
866 /* as all the arrays are the same size, checking only dscene.objects is sufficient */
867 const bool update_all = dscene->objects.need_realloc();
868
869 /* Parallel object update, with grain size to avoid too much threading overhead
870 * for individual objects. */
871 static const int OBJECTS_PER_TASK = 32;
872 parallel_for(blocked_range<size_t>(0, scene->objects.size(), OBJECTS_PER_TASK),
873 [&](const blocked_range<size_t> &r) {
874 for (size_t i = r.begin(); i != r.end(); i++) {
875 Object *ob = state.scene->objects[i];
876 device_update_object_transform(&state, ob, update_all, scene);
877 }
878 });
879
880 if (progress.get_cancel()) {
881 return;
882 }
883
884 dscene->objects.copy_to_device_if_modified();
885 if (state.need_motion == Scene::MOTION_PASS ||
887 {
888 dscene->object_motion_pass.copy_to_device();
889 }
890 else if (state.need_motion == Scene::MOTION_BLUR) {
891 dscene->object_motion.copy_to_device();
892 }
893
894 dscene->data.bvh.have_motion = state.have_motion;
895 dscene->data.bvh.have_curves = state.have_curves;
896 dscene->data.bvh.have_points = state.have_points;
897 dscene->data.bvh.have_volumes = state.have_volumes;
898
899 dscene->objects.clear_modified();
900 dscene->object_motion_pass.clear_modified();
901 dscene->object_motion.clear_modified();
902}
903
905 DeviceScene *dscene,
906 Scene *scene,
907 Progress &progress)
908{
909 if (!need_update()) {
910 return;
911 }
912
913 if (update_flags & (OBJECT_ADDED | OBJECT_REMOVED)) {
914 dscene->objects.tag_realloc();
916 dscene->object_motion.tag_realloc();
917 dscene->object_flag.tag_realloc();
919
920 /* If objects are added to the scene or deleted, the object indices might change, so we need to
921 * update the root indices of the volume octrees. */
922 scene->volume_manager->tag_update_indices();
923 }
924
925 if (update_flags & HOLDOUT_MODIFIED) {
926 dscene->object_flag.tag_modified();
927 }
928
929 if (update_flags & PARTICLE_MODIFIED) {
930 dscene->objects.tag_modified();
931 }
932
933 LOG_INFO << "Total " << scene->objects.size() << " objects.";
934
935 device_free(device, dscene, false);
936
937 if (scene->objects.empty()) {
938 return;
939 }
940
941 {
942 /* Assign object IDs. */
943 const scoped_callback_timer timer([scene](double time) {
944 if (scene->update_stats) {
945 scene->update_stats->object.times.add_entry({"device_update (assign index)", time});
946 }
947 });
948
949 int index = 0;
950 for (Object *object : scene->objects) {
951 object->index = index++;
952
953 /* this is a bit too broad, however a bigger refactor might be needed to properly separate
954 * update each type of data (transform, flags, etc.) */
955 if (object->is_modified()) {
956 dscene->objects.tag_modified();
958 dscene->object_motion.tag_modified();
959 dscene->object_flag.tag_modified();
961 }
962
963 /* Update world object index. */
964 if (!object->get_geometry()->is_light()) {
965 continue;
966 }
967
968 const Light *light = static_cast<const Light *>(object->get_geometry());
969 if (light->is_background_light()) {
970 dscene->data.background.object_index = object->index;
971 }
972 }
973 }
974
975 {
976 /* set object transform matrices, before applying static transforms */
977 const scoped_callback_timer timer([scene](double time) {
978 if (scene->update_stats) {
979 scene->update_stats->object.times.add_entry(
980 {"device_update (copy objects to device)", time});
981 }
982 });
983
984 progress.set_status("Updating Objects", "Copying Transformations to device");
985 device_update_transforms(dscene, scene, progress);
986 }
987
988 for (Object *object : scene->objects) {
989 object->clear_modified();
990 }
991}
992
994 DeviceScene *dscene,
995 Scene *scene,
996 Progress & /*progress*/,
997 bool bounds_valid)
998{
999 if (!need_update() && !need_flags_update) {
1000 return;
1001 }
1002
1003 const scoped_callback_timer timer([scene](double time) {
1004 if (scene->update_stats) {
1005 scene->update_stats->object.times.add_entry({"device_update_flags", time});
1006 }
1007 });
1008
1009 if (bounds_valid) {
1010 /* Object flags and calculations related to volume depend on proper bounds calculated, which
1011 * might not be available yet when object flags are updated for displacement or hair
1012 * transparency calculation. In this case do not clear the need_flags_update, so that these
1013 * values which depend on bounds are re-calculated when the device_update process comes back
1014 * here from the "Updating Objects Flags" stage. */
1015 update_flags = UPDATE_NONE;
1016 need_flags_update = false;
1017 }
1018
1019 if (scene->objects.empty()) {
1020 return;
1021 }
1022
1023 /* Object info flag. */
1024 uint *object_flag = dscene->object_flag.data();
1025
1026 /* Object volume intersection. */
1027 vector<Object *> volume_objects;
1028 bool has_volume_objects = false;
1029 for (Object *object : scene->objects) {
1030 if (object->geometry->has_volume) {
1031 /* If the bounds are not valid it is not always possible to calculate the volume step, and
1032 * the step size is not needed for the displacement. So, delay calculation of the volume
1033 * step size until the final bounds are known. */
1034 if (bounds_valid) {
1035 volume_objects.push_back(object);
1036 }
1037 has_volume_objects = true;
1038 }
1039 }
1040
1041 for (Object *object : scene->objects) {
1042 if (object->geometry->has_volume) {
1043 object_flag[object->index] |= SD_OBJECT_HAS_VOLUME;
1044 object_flag[object->index] &= ~SD_OBJECT_HAS_VOLUME_ATTRIBUTES;
1045
1046 for (const Attribute &attr : object->geometry->attributes.attributes) {
1047 if (attr.element == ATTR_ELEMENT_VOXEL) {
1048 object_flag[object->index] |= SD_OBJECT_HAS_VOLUME_ATTRIBUTES;
1049 }
1050 }
1051 }
1052 else {
1053 object_flag[object->index] &= ~(SD_OBJECT_HAS_VOLUME | SD_OBJECT_HAS_VOLUME_ATTRIBUTES);
1054 }
1055
1056 if (object->is_shadow_catcher) {
1057 object_flag[object->index] |= SD_OBJECT_SHADOW_CATCHER;
1058 }
1059 else {
1060 object_flag[object->index] &= ~SD_OBJECT_SHADOW_CATCHER;
1061 }
1062
1063 /* Corner normals might get removed by subdivision and displacement. */
1064 if (object->geometry->attributes.find(ATTR_STD_CORNER_NORMAL)) {
1065 object_flag[object->index] |= SD_OBJECT_HAS_CORNER_NORMALS;
1066 }
1067 else {
1068 object_flag[object->index] &= ~SD_OBJECT_HAS_CORNER_NORMALS;
1069 }
1070
1071 if (bounds_valid) {
1072 object->intersects_volume = false;
1073 for (Object *volume_object : volume_objects) {
1074 if (object == volume_object) {
1075 continue;
1076 }
1077 if (object->bounds.intersects(volume_object->bounds)) {
1078 object_flag[object->index] |= SD_OBJECT_INTERSECTS_VOLUME;
1079 object->intersects_volume = true;
1080 break;
1081 }
1082 }
1083 }
1084 else if (has_volume_objects) {
1085 /* Not really valid, but can't make more reliable in the case
1086 * of bounds not being up to date.
1087 */
1088 object_flag[object->index] |= SD_OBJECT_INTERSECTS_VOLUME;
1089 }
1090 }
1091
1092 /* Copy object flag. */
1093 dscene->object_flag.copy_to_device();
1094 dscene->object_flag.clear_modified();
1095}
1096
1097/* NOTE: Only use for attributes that are guaranteed to exist.
1098 * Otherwise it is not possible to encode offset and motion flag. */
1100 const PointCloud &pointcloud,
1101 const size_t attr_map_offset,
1102 const AttributeStandard std,
1103 int &kobject_offset_and_flag)
1104{
1105 const Attribute *attribute = pointcloud.attributes.find(std);
1106 const int offset =
1107 find_attribute(dscene.attributes_map.data(), attr_map_offset, PRIMITIVE_GSPLAT, std).offset;
1108
1109 /* The function is only working correctly for attributes that are required.
1110 * Also check that the most significant bit is not set, as it will be lost during encoding. */
1111 assert(offset != ATTR_STD_NOT_FOUND);
1112 assert((uint(offset) >> 31U) == 0);
1113
1114 const int offset_and_flag = (offset << 1) | (attribute ? attribute->has_motion() : 0);
1115
1116 if (kobject_offset_and_flag == offset_and_flag) {
1117 return false;
1118 }
1119 kobject_offset_and_flag = offset_and_flag;
1120 return true;
1121}
1122
1124 const size_t attr_map_offset,
1125 const AttributeStandard std,
1126 int &kobject_offset)
1127{
1128 const int offset =
1129 find_attribute(dscene.attributes_map.data(), attr_map_offset, PRIMITIVE_GSPLAT, std).offset;
1130 if (kobject_offset == offset) {
1131 return false;
1132 }
1133 kobject_offset = offset;
1134 return true;
1135}
1136
1138 DeviceScene *dscene,
1139 Scene *scene)
1140{
1141 if (dscene->objects.size() == 0) {
1142 return;
1143 }
1144
1145 KernelObject *kobjects = dscene->objects.data();
1146
1147 bool update = false;
1148
1149 for (Object *object : scene->objects) {
1150 Geometry *geom = object->geometry;
1151
1152 KernelObject &kobject = kobjects[object->index];
1153
1154 /* An object attribute map cannot have a zero offset because mesh maps come first. */
1155 size_t attr_map_offset = object->attr_map_offset;
1156 if (attr_map_offset == 0) {
1157 attr_map_offset = geom->attr_map_offset;
1158 }
1159
1160 if (kobject.attribute_map_offset != attr_map_offset) {
1161 kobject.attribute_map_offset = attr_map_offset;
1162 update = true;
1163 }
1164
1165 /* Cached attribute offsets for quick lookup. */
1166 int position_offset = ATTR_STD_NOT_FOUND;
1167 if (geom->is_mesh() || geom->is_volume()) {
1168 int normal_offset = ATTR_STD_NOT_FOUND;
1169 position_offset = find_attribute(dscene->attributes_map.data(),
1170 attr_map_offset,
1173 .offset;
1174
1175 normal_offset = find_attribute(dscene->attributes_map.data(),
1176 attr_map_offset,
1179 .offset;
1180 if (normal_offset == ATTR_STD_NOT_FOUND) {
1181 normal_offset = find_attribute(dscene->attributes_map.data(),
1182 attr_map_offset,
1185 .offset;
1186 }
1187 assert(position_offset != ATTR_STD_NOT_FOUND ||
1188 static_cast<Mesh *>(geom)->num_triangles() == 0);
1189 assert(normal_offset != ATTR_STD_NOT_FOUND ||
1190 static_cast<Mesh *>(geom)->num_triangles() == 0);
1191 if (kobject.mesh_volume.normal_offset != normal_offset) {
1192 kobject.mesh_volume.normal_offset = normal_offset;
1193 update = true;
1194 }
1195 }
1196 else if (geom->is_hair()) {
1197 position_offset = find_attribute(dscene->attributes_map.data(),
1198 attr_map_offset,
1201 .offset;
1202 assert(position_offset != ATTR_STD_NOT_FOUND || static_cast<Hair *>(geom)->num_keys() == 0);
1203 }
1204 else if (geom->is_pointcloud()) {
1205 const PointCloud *pointcloud = static_cast<const PointCloud *>(geom);
1206 position_offset = find_attribute(dscene->attributes_map.data(),
1207 attr_map_offset,
1210 .offset;
1211 assert(position_offset != ATTR_STD_NOT_FOUND || pointcloud->num_points() == 0);
1212 if (pointcloud->primitive_type() & PRIMITIVE_GSPLAT) {
1214 *dscene,
1215 *pointcloud,
1216 attr_map_offset,
1218 kobject.gsplat.radiance_base_offset_and_flag);
1220 *dscene,
1221 *pointcloud,
1222 attr_map_offset,
1224 kobject.gsplat.scale_offset_and_flag);
1226 *dscene,
1227 *pointcloud,
1228 attr_map_offset,
1230 kobject.gsplat.rotation_offset_and_flag);
1231
1233 *dscene,
1234 attr_map_offset,
1236 kobject.gsplat.radiance_spherical_harmonics_rest_offset);
1237 }
1238 }
1239 if (kobject.position_offset != position_offset) {
1240 kobject.position_offset = position_offset;
1241 update = true;
1242 }
1243
1244 const int numverts = object_num_motion_verts(geom);
1245 if (kobject.numverts != numverts) {
1246 kobject.numverts = numverts;
1247 update = true;
1248 }
1249 }
1250
1251 if (update) {
1252 dscene->objects.copy_to_device();
1253 }
1254}
1255
1256void ObjectManager::device_free(Device * /*unused*/, DeviceScene *dscene, bool force_free)
1257{
1258 dscene->objects.free_if_need_realloc(force_free);
1259 dscene->object_motion_pass.free_if_need_realloc(force_free);
1260 dscene->object_motion.free_if_need_realloc(force_free);
1261 dscene->object_flag.free_if_need_realloc(force_free);
1262 dscene->object_prim_offset.free_if_need_realloc(force_free);
1263}
1264
1266{
1267 /* todo: normals and displacement should be done before applying transform! */
1268 /* todo: create objects/geometry in right order! */
1269
1270 /* counter geometry users */
1271 map<Geometry *, int> geometry_users;
1272 const Scene::MotionType need_motion = scene->need_motion();
1273 const bool motion_blur = need_motion == Scene::MOTION_BLUR;
1274 const bool apply_to_motion = need_motion != Scene::MOTION_PASS &&
1275 need_motion != Scene::MOTION_PASS_INTERACTIVE;
1276 int i = 0;
1277
1278 for (Object *object : scene->objects) {
1279 const map<Geometry *, int>::iterator it = geometry_users.find(object->geometry);
1280
1281 if (it == geometry_users.end()) {
1282 geometry_users[object->geometry] = 1;
1283 }
1284 else {
1285 it->second++;
1286 }
1287 }
1288
1289 if (progress.get_cancel()) {
1290 return;
1291 }
1292
1293 uint *object_flag = dscene->object_flag.data();
1294
1295 /* apply transforms for objects with single user geometry */
1296 for (Object *object : scene->objects) {
1297 /* Annoying feedback loop here: we can't use is_instanced() because
1298 * it'll use uninitialized transform_applied flag.
1299 *
1300 * Could be solved by moving reference counter to Geometry.
1301 */
1302 Geometry *geom = object->geometry;
1303 bool apply = (geometry_users[geom] == 1) && !geom->has_surface_bssrdf &&
1304 !geom->has_true_displacement();
1305
1306 if (geom->is_mesh()) {
1307 Mesh *mesh = static_cast<Mesh *>(geom);
1308 apply = apply && mesh->get_subdivision_type() == Mesh::SUBDIVISION_NONE;
1309 }
1310 else if (geom->is_hair() || geom->is_pointcloud()) {
1311 /* Can't apply non-uniform scale to curves and points, this can't be
1312 * represented by control points and radius alone. */
1313 float scale;
1314 apply = apply && transform_uniform_scale(object->tfm, scale);
1315 }
1316
1317 /* Applying transform on Gaussian splats is not trivial as in general case it requires
1318 * non-trivial math for rotating spherical harmonics. */
1319 if (geom->is_pointcloud()) {
1320 const PointCloud *pointcloud = static_cast<const PointCloud *>(geom);
1321 apply = apply && ((pointcloud->primitive_type() & PRIMITIVE_GSPLAT) == 0);
1322 }
1323
1324 if (apply) {
1325 if (!(motion_blur && object->use_motion())) {
1326 if (!geom->transform_applied) {
1327 object->apply_transform(apply_to_motion);
1328 geom->transform_applied = true;
1329
1330 if (progress.get_cancel()) {
1331 return;
1332 }
1333 }
1334
1335 object_flag[i] |= SD_OBJECT_TRANSFORM_APPLIED;
1336 }
1337 }
1338
1339 i++;
1340 }
1341}
1342
1343void ObjectManager::tag_update(Scene *scene, const uint32_t flag)
1344{
1345 update_flags |= flag;
1346
1347 /* avoid infinite loops if the geometry manager tagged us for an update */
1348 if ((flag & GEOMETRY_MANAGER) == 0) {
1349 uint32_t geometry_flag = GeometryManager::OBJECT_MANAGER;
1350
1351 /* Also notify in case added or removed objects were instances, as no Geometry might have been
1352 * added or removed, but the BVH still needs to updated. */
1353 if ((flag & (OBJECT_ADDED | OBJECT_REMOVED)) != 0) {
1355 }
1356
1357 if ((flag & TRANSFORM_MODIFIED) != 0) {
1358 geometry_flag |= GeometryManager::TRANSFORM_MODIFIED;
1359 }
1360
1361 if ((flag & VISIBILITY_MODIFIED) != 0) {
1362 geometry_flag |= GeometryManager::VISIBILITY_MODIFIED;
1363 }
1364
1365 scene->geometry_manager->tag_update(scene, geometry_flag);
1366 }
1367
1368 scene->light_manager->tag_update(scene, LightManager::OBJECT_MANAGER);
1369
1370 /* Integrator's shadow catcher settings depends on object visibility settings. */
1371 if (flag & (OBJECT_ADDED | OBJECT_REMOVED | OBJECT_MODIFIED)) {
1373 }
1374}
1375
1377{
1378 return update_flags != UPDATE_NONE;
1379}
1380
1382{
1383 string manifest = "{";
1384
1385 unordered_set<ustring> objects;
1386 for (Object *object : scene->objects) {
1387 if (objects.contains(object->name)) {
1388 continue;
1389 }
1390 objects.insert(object->name);
1391 const uint32_t hash_name = util_murmur_hash3(object->name.c_str(), object->name.length(), 0);
1392 manifest += string_printf("\"%s\":\"%08x\",", object->name.c_str(), hash_name);
1393 }
1394 manifest[manifest.size() - 1] = '}';
1395 return manifest;
1396}
1397
1399{
1400 string manifest = "{";
1401 unordered_set<ustring> assets;
1402 for (Object *ob : scene->objects) {
1403 if (assets.contains(ob->asset_name)) {
1404 continue;
1405 }
1406 assets.insert(ob->asset_name);
1407 const uint32_t hash_asset = util_murmur_hash3(
1408 ob->asset_name.c_str(), ob->asset_name.length(), 0);
1409 manifest += string_printf("\"%s\":\"%08x\",", ob->asset_name.c_str(), hash_asset);
1410 }
1411 manifest[manifest.size() - 1] = '}';
1412 return manifest;
1413}
1414
list< Attribute > attributes
Attribute * find(ustring name) const
ImageHandle & data_voxel_for_write()
AttributeElement element
bool has_motion() const
BoundBox transformed(const Transform *tfm) const
Definition boundbox.h:134
__forceinline bool valid() const
Definition boundbox.h:127
__forceinline float3 size() const
Definition boundbox.h:122
__forceinline bool intersects(const BoundBox &other)
Definition boundbox.h:157
__forceinline void grow(const float3 &pt)
Definition boundbox.h:35
bool need_flags_update
device_vector< DecomposedTransform > object_motion
Definition devicescene.h:44
device_vector< Transform > object_motion_pass
Definition devicescene.h:43
device_vector< AttributeMap > attributes_map
Definition devicescene.h:52
device_vector< float > volume_step_size
Definition devicescene.h:95
device_vector< uint > object_prim_offset
Definition devicescene.h:46
device_vector< uint > object_flag
Definition devicescene.h:45
KernelData data
device_vector< KernelObject > objects
Definition devicescene.h:42
bool transform_applied
bool has_true_displacement() const
bool is_volume() const
bool is_pointcloud() const
bool is_hair() const
bool has_surface_bssrdf
virtual PrimitiveType primitive_type() const =0
size_t attr_map_offset
AttributeSet attributes
bool is_mesh() const
Definition hair.h:13
ImageMetaData metadata(Progress &progress)
Transform transform_3d
int64_t nanovdb_byte_size
void tag_update(Scene *scene, const uint32_t flag)
bool is_background_light() const
AttributeSet subd_attributes
Definition scene/mesh.h:169
@ SUBDIVISION_NONE
Definition scene/mesh.h:114
void tag_update(Scene *scene, const uint32_t flag)
string get_cryptomatte_objects(Scene *scene)
void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress)
void device_update_object_transform(UpdateObjectTransformState *state, Object *ob, bool update_all, const Scene *scene)
void device_free(Device *device, DeviceScene *dscene, bool force_free)
string get_cryptomatte_assets(Scene *scene)
bool need_update() const
void device_update_geom_offsets(Device *device, DeviceScene *dscene, Scene *scene)
void device_update_prim_offsets(Device *device, DeviceScene *dscene, Scene *scene)
void device_update_transforms(DeviceScene *dscene, Scene *scene, Progress &progress)
void apply_static_transforms(DeviceScene *dscene, Scene *scene, Progress &progress)
void device_update_flags(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress, bool bounds_valid=true)
void update_interactive_motion(Scene *scene)
void compute_bounds(bool motion_blur)
void update_motion(Scene::MotionType need_motion)
bool use_motion() const
NODE_DECLARE BoundBox bounds
size_t attr_map_offset
bool usable_as_light() const
int index
void set_motion_tfm(Transform tfm, const int step_index)
vector< ParamValue > attributes
int get_device_index() const
int motion_step(const float time) const
void set_tfm(Transform tfm)
void apply_transform(bool apply_to_motion)
bool has_light_linking() const
bool tfm_equals(Transform tfm)
bool is_traceable() const
float compute_volume_step_size(Progress &progress) const
uint visibility_for_tracing() const
void tag_update(Scene *scene)
~Object() override
float motion_time(const int step) const
bool has_shadow_linking() const
void adjust_volume_tfm(Transform &tfm)
bool intersects_volume
array< Particle > particles
Definition particles.h:41
size_t num_points() const
PrimitiveType primitive_type() const override
bool get_cancel() const
Definition progress.h:77
void set_status(const string &status_, const string &substatus_="")
Definition progress.h:248
Definition scene.h:133
unique_ptr< ObjectManager > object_manager
Definition scene.h:171
MotionType need_motion() const
Definition scene.cpp:429
unique_ptr< LightManager > light_manager
Definition scene.h:167
unique_ptr< SceneUpdateStats > update_stats
Definition scene.h:197
void tag_shadow_catcher_modified()
Definition scene.cpp:838
MotionType
Definition scene.h:207
@ MOTION_PASS
Definition scene.h:207
@ MOTION_BLUR
Definition scene.h:207
@ MOTION_PASS_INTERACTIVE
Definition scene.h:207
Camera * camera
Definition scene.h:145
unique_ptr_vector< ParticleSystem > particle_systems
Definition scene.h:160
unique_ptr< GeometryManager > geometry_manager
Definition scene.h:170
unique_ptr_vector< Object > objects
Definition scene.h:162
Integrator * integrator
Definition scene.h:149
map< ustring, int > lightgroups
Definition scene.h:139
unique_ptr< VolumeManager > volume_manager
Definition scene.h:175
bool has_volume_attribute_dependency
bool has_volume
EmissionSampling emission_sampling
bool has_volume_spatial_varying
size_t size() const
size_t size() const
T * alloc(const size_t width, const size_t height=0)
void free_if_need_realloc(bool force_free)
size_t size() const
#define LIGHT_LINK_SET_MAX
#define OBJECT_MOTION_PASS_SIZE
#define LIGHTGROUP_NONE
#define LIGHT_LINK_MASK_ALL
#define SHADOW_CATCHER_OBJECT_VISIBILITY(is_shadow_catcher, visibility)
#define CCL_NAMESPACE_END
ccl_device_forceinline float3 make_float3(const float x, const float y, const float z)
float hash_uint2_to_float(uint kx, uint ky)
#define assert(assertion)
#define FLT_MAX
#define index(i)
#define attribute(slot)
VecBase< float, D > normalize(VecOp< float, D >) RET
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
float3x3 scale(float3x3 mat, float2 scale)
float3 transform_direction(float3x3 mat, float3 direction)
float reduce_min(float2 a)
float average(float2 a)
const int state
ccl_device_inline AttributeDescriptor find_attribute(const ccl_global AttributeMap *attributes_map, uint attr_offset, const int prim, const uint64_t id)
ccl_device_inline float object_volume_density(KernelGlobals kg, const int object)
ccl_device_inline uint particle_index(KernelGlobals kg, const int particle)
@ PRIMITIVE_GSPLAT
@ PRIMITIVE_CURVE_THICK
@ PRIMITIVE_TRIANGLE
@ PRIMITIVE_POINT
@ PATH_RAY_VISIBILITY_VOLUME_SCATTER
@ PATH_RAY_VISIBILITY_TRANSMIT
@ PATH_RAY_VISIBILITY_DIFFUSE
@ PATH_RAY_VISIBILITY_OBJECT_ALL
@ PATH_RAY_VISIBILITY_GLOSSY
@ SD_OBJECT_MOTION
@ SD_OBJECT_HAS_VOLUME_ATTRIBUTES
@ SD_OBJECT_HAS_CORNER_NORMALS
@ SD_OBJECT_HAS_VOLUME
@ SD_OBJECT_INTERSECTS_VOLUME
@ SD_OBJECT_NEGATIVE_SCALE
@ SD_OBJECT_HOLDOUT_MASK
@ SD_OBJECT_HAS_VOLUME_MOTION
@ SD_OBJECT_CAUSTICS_RECEIVER
@ SD_OBJECT_SHADOW_CATCHER
@ SD_OBJECT_TRANSFORM_APPLIED
@ SD_OBJECT_HAS_VERTEX_MOTION
@ SD_OBJECT_CAUSTICS_CASTER
@ EMISSION_SAMPLING_NONE
@ BVH_LAYOUT_MULTI_HIPRT_EMBREE
@ BVH_LAYOUT_METAL
@ BVH_LAYOUT_MULTI_HIPRT
@ BVH_LAYOUT_HIPRT
@ BVH_LAYOUT_MULTI_METAL
@ BVH_LAYOUT_MULTI_METAL_EMBREE
@ ATTR_ELEMENT_VOXEL
AttributeStandard
@ ATTR_STD_GSPLAT_SCALE
@ ATTR_STD_VERTEX_NORMAL
@ ATTR_STD_NOT_FOUND
@ ATTR_STD_GSPLAT_RADIANCE_BASE
@ ATTR_STD_VOLUME_VELOCITY
@ ATTR_STD_GSPLAT_ROTATION
@ ATTR_STD_POSITION
@ ATTR_STD_CORNER_NORMAL
@ ATTR_STD_GSPLAT_RADIANCE_SPHERICAL_HARMONICS_REST
#define LOG_INFO
Definition log.h:106
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263
ccl_device_inline dual3 fabs(const ccl_private dual3 &a)
Definition math_dual.h:241
CCL_NAMESPACE_BEGIN ccl_device_inline float2 zero_float2()
Definition math_float2.h:13
ccl_device_inline float3 one_float3()
Definition math_float3.h:26
CCL_NAMESPACE_BEGIN ccl_device_inline float3 zero_float3()
Definition math_float3.h:17
uint32_t util_murmur_hash3(const void *key, const int len, const uint32_t seed)
float util_hash_to_float(const uint32_t hash)
#define SOCKET_POINT(name, ui_name, default_value,...)
Definition node_type.h:225
#define SOCKET_FLOAT(name, ui_name, default_value,...)
Definition node_type.h:219
#define SOCKET_INT(name, ui_name, default_value,...)
Definition node_type.h:213
#define SOCKET_NODE(name, ui_name, node_type,...)
Definition node_type.h:248
#define SOCKET_TRANSFORM(name, ui_name, default_value,...)
Definition node_type.h:233
#define SOCKET_UINT(name, ui_name, default_value,...)
Definition node_type.h:215
#define NODE_DEFINE(structname)
Definition node_type.h:157
#define SOCKET_COLOR(name, ui_name, default_value,...)
Definition node_type.h:221
#define SOCKET_TRANSFORM_ARRAY(name, ui_name, default_value,...)
Definition node_type.h:308
#define SOCKET_BOOLEAN(name, ui_name, default_value,...)
Definition node_type.h:211
#define SOCKET_POINT2(name, ui_name, default_value,...)
Definition node_type.h:229
#define SOCKET_STRING(name, ui_name, default_value,...)
Definition node_type.h:231
#define SOCKET_UINT64(name, ui_name, default_value,...)
Definition node_type.h:217
int BVHLayoutMask
Definition params.h:50
#define fminf
static bool update_gsplat_std_point_attribute_offset_and_flag(const DeviceScene &dscene, const PointCloud &pointcloud, const size_t attr_map_offset, const AttributeStandard std, int &kobject_offset_and_flag)
static bool update_gsplat_std_point_attribute_offset(const DeviceScene &dscene, const size_t attr_map_offset, const AttributeStandard std, int &kobject_offset)
static int object_num_motion_verts(Geometry *geom)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
CCL_NAMESPACE_BEGIN string string_printf(const char *format,...)
Definition string.cpp:25
Transform tfm
uint64_t shadow_set_membership
Transform itfm
float dupli_uv[2]
float shadow_terminator_geometry_offset
float cryptomatte_asset
uint16_t num_tfm_steps
uint blocker_shadow_set
uint attribute_map_offset
uint receiver_light_set
uint64_t light_set_membership
float shadow_terminator_shading_offset
float dupli_generated[3]
uint16_t num_geom_steps
float cryptomatte_object
static NodeType * add(const char *name, CreateFunc create, Type type=NONE, const NodeType *base=nullptr)
void set(const SocketType &input, bool value)
ustring name
Definition graph/node.h:178
bool is_modified() const
Node(const NodeType *type, ustring name=ustring())
map< ParticleSystem *, int > particle_offset
DecomposedTransform * object_motion
Scene::MotionType need_motion
float z
Definition sky_math.h:136
float y
Definition sky_math.h:136
float x
Definition sky_math.h:136
void transform_motion_decompose(DecomposedTransform *decomp, const Transform *motion, const size_t size)
ccl_device_inline Transform transform_identity()
Definition transform.h:355
ccl_device void transform_motion_array_interpolate(ccl_private Transform *tfm, const ccl_global DecomposedTransform *motion, const int numsteps, const float time)
Definition transform.h:629
ccl_device_inline Transform transform_empty()
Definition transform.h:449
ccl_device_inline bool transform_negative_scale(const Transform &tfm)
Definition transform.h:429
ccl_device_inline Transform transform_inverse(const Transform tfm)
Definition transform.h:563
ccl_device_inline Transform transform_translate(const float3 t)
Definition transform.h:296
ccl_device_inline bool transform_uniform_scale(const Transform &tfm, float &scale)
Definition transform.h:406