79 SOCKET_NODE(geometry,
"Geometry", Geometry::get_node_base_type());
87 SOCKET_BOOLEAN(hide_on_missing_motion,
"Hide on Missing Motion",
false);
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);
98 SOCKET_BOOLEAN(is_caustics_receiver,
"Receive Shadow Caustics",
false);
102 SOCKET_NODE(particle_system,
"Particle System", ParticleSystem::get_node_type());
108 SOCKET_UINT(receiver_light_set,
"Light Set Index", 0);
110 SOCKET_UINT(blocker_shadow_set,
"Shadow Set Index", 0);
118 particle_system =
nullptr;
133 bool have_motion =
false;
135 for (
size_t i = 0; i < motion.size(); i++) {
149 if (have_motion && i == (motion.size() - 1)) {
151 motion.resize(motion.size() - 1);
160 have_motion = have_motion || motion[i] != tfm;
171 const BoundBox mbounds = geometry->bounds;
182 for (
float t = 0.0f; t < 1.0f; t += (1.0f / 128.0f)) {
191 if (geometry->transform_applied) {
206 geometry->apply_transform(tfm, apply_to_motion);
211 geometry->transform_negative_scaled =
true;
215 geometry->compute_bounds();
230 if (use_holdout_is_modified()) {
234 if (is_shadow_catcher_is_modified()) {
241 if (tfm_is_modified() || motion_is_modified()) {
243 if (geometry->has_volume) {
248 if (visibility_is_modified()) {
252 for (
Node *
node : geometry->get_used_shaders()) {
266 return (motion.size() > 1);
271 return (
use_motion()) ? 2.0f *
step / (motion.size() - 1) - 1.0f : 0.0f;
290 if (geometry->is_light()) {
309 if (geometry->is_light()) {
311 assert(
static_cast<const Light *
>(geometry)->is_background_light());
312 for (
const Node *
node : geometry->get_used_shaders()) {
315 return shader->get_volume_step_rate();
322 if (!geometry->is_mesh() && !geometry->is_volume()) {
326 Mesh *mesh =
static_cast<Mesh *
>(geometry);
335 for (
Node *
node : mesh->get_used_shaders()) {
339 step_rate =
fminf(shader->get_volume_step_rate(), step_rate);
351 if (geometry->is_volume()) {
363 float voxel_step_size = volume->get_step_size();
365 if (voxel_step_size == 0.0f) {
374 else if (volume->get_object_space()) {
376 const float3 size =
make_float3(voxel_step_size, voxel_step_size, voxel_step_size);
380 if (voxel_step_size > 0.0f) {
381 step_size =
fminf(voxel_step_size, step_size);
393 step_size *= step_rate;
424 for (
Node *
node : geom->get_used_shaders()) {
435 if (get_receiver_light_set()) {
448 if (get_blocker_shadow_set()) {
462 if (geometry->is_volume()) {
467 const uint name_hash = hash_string(
name.c_str());
488 return tfm == get_tfm();
495 motion[step_index] = tfm;
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];
518 const bool use_motion = ob->use_motion();
520 array<Transform> motion = ob->get_motion();
521 if (motion.empty()) {
530 ob->set_motion(motion);
532 if (use_motion && ob->motion_is_modified()) {
539 tag_update(scene, TRANSFORM_MODIFIED);
547 if (
static_cast<Volume *
>(geom)->get_object_space()) {
559 geom->
is_hair() ?
static_cast<Hair *
>(geom)->num_keys() :
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);
583 ob->particle_index +
state->particle_offset[ob->particle_system] :
588 kobject.
color[0] = color.
x;
589 kobject.
color[1] = color.
y;
590 kobject.
color[2] = color.
z;
591 kobject.
alpha = ob->alpha;
600 ob->receiver_light_set;
604 ob->blocker_shadow_set;
607 if (geom->get_use_motion_blur()) {
608 state->have_motion =
true;
643 kobject.mesh_volume.volume_velocity_scale = volume->get_velocity_scale();
647 Mesh *mesh =
static_cast<Mesh *
>(geom);
670 tfm_pre = ob->motion[0];
671 tfm_post = ob->motion[ob->motion.size() - 1];
683 tfm_pre = tfm_pre * itfm;
684 tfm_post = tfm_post * itfm;
694 object_motion_pass[motion_pass_offset + 0] = tfm_pre;
695 object_motion_pass[motion_pass_offset + 1] = tfm_post;
702 if (ob->tfm_is_modified() || ob->motion_is_modified() || update_all) {
708 state->have_motion =
true;
716 kobject.
dupli_uv[0] = ob->dupli_uv[0];
717 kobject.
dupli_uv[1] = ob->dupli_uv[1];
723 kobject.mesh_volume.num_prims =
static_cast<Mesh *
>(geom)->num_triangles();
728 if (ob->asset_name_is_modified() || update_all) {
731 ob->asset_name.c_str(), ob->asset_name.length(), 0);
737 (1.0f - 0.5f * ob->shadow_terminator_shading_offset);
744 if (ob->is_caustics_caster) {
747 if (ob->is_caustics_receiver) {
752 if (ob->use_holdout) {
759 state->have_curves =
true;
762 state->have_points =
true;
765 state->have_volumes =
true;
786 if (!scene->
integrator->get_use_light_tree()) {
787 const BVHLayoutMask layout_mask = device->get_bvh_layout_mask(dscene->
data.kernel_features);
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;
807 prim_offset = geom->prim_offset;
811 object_prim_offset[obj_index] = prim_offset;
822 state.have_motion =
false;
823 state.have_curves =
false;
824 state.have_points =
false;
825 state.have_volumes =
false;
827 state.queue_start_object = 0;
831 state.object_motion =
nullptr;
832 state.object_motion_pass =
nullptr;
843 uint motion_offset = 0;
846 *motion_offsets = motion_offset;
851 motion_offset += ob->motion.size();
860 int numparticles = 1;
862 state.particle_offset[psys] = numparticles;
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);
880 if (progress.get_cancel()) {
884 dscene->objects.copy_to_device_if_modified();
888 dscene->object_motion_pass.copy_to_device();
891 dscene->object_motion.copy_to_device();
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;
899 dscene->objects.clear_modified();
900 dscene->object_motion_pass.clear_modified();
901 dscene->object_motion.clear_modified();
945 scene->
update_stats->object.times.add_entry({
"device_update (assign index)", time});
951 object->index =
index++;
964 if (!object->get_geometry()->is_light()) {
968 const Light *light =
static_cast<const Light *
>(
object->get_geometry());
970 dscene->
data.background.object_index =
object->index;
980 {
"device_update (copy objects to device)", time});
984 progress.
set_status(
"Updating Objects",
"Copying Transformations to device");
989 object->clear_modified();
1005 scene->
update_stats->object.times.add_entry({
"device_update_flags", time});
1028 bool has_volume_objects =
false;
1030 if (object->geometry->has_volume) {
1035 volume_objects.push_back(
object);
1037 has_volume_objects =
true;
1042 if (object->geometry->has_volume) {
1056 if (object->is_shadow_catcher) {
1072 object->intersects_volume =
false;
1073 for (
Object *volume_object : volume_objects) {
1074 if (
object == volume_object) {
1079 object->intersects_volume =
true;
1084 else if (has_volume_objects) {
1101 const size_t attr_map_offset,
1103 int &kobject_offset_and_flag)
1112 assert((uint(offset) >> 31U) == 0);
1114 const int offset_and_flag = (offset << 1) | (
attribute ?
attribute->has_motion() : 0);
1116 if (kobject_offset_and_flag == offset_and_flag) {
1119 kobject_offset_and_flag = offset_and_flag;
1124 const size_t attr_map_offset,
1126 int &kobject_offset)
1130 if (kobject_offset == offset) {
1133 kobject_offset = offset;
1147 bool update =
false;
1155 size_t attr_map_offset =
object->attr_map_offset;
1156 if (attr_map_offset == 0) {
1188 static_cast<Mesh *
>(geom)->num_triangles() == 0);
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;
1218 kobject.gsplat.radiance_base_offset_and_flag);
1224 kobject.gsplat.scale_offset_and_flag);
1230 kobject.gsplat.rotation_offset_and_flag);
1236 kobject.gsplat.radiance_spherical_harmonics_rest_offset);
1245 if (kobject.
numverts != numverts) {
1271 map<Geometry *, int> geometry_users;
1279 const map<Geometry *, int>::iterator it = geometry_users.find(object->geometry);
1281 if (it == geometry_users.end()) {
1282 geometry_users[
object->geometry] = 1;
1307 Mesh *mesh =
static_cast<Mesh *
>(geom);
1325 if (!(motion_blur && object->
use_motion())) {
1327 object->apply_transform(apply_to_motion);
1345 update_flags |= flag;
1383 string manifest =
"{";
1385 unordered_set<ustring> objects;
1387 if (objects.contains(object->
name)) {
1390 objects.insert(object->
name);
1394 manifest[manifest.size() - 1] =
'}';
1400 string manifest =
"{";
1401 unordered_set<ustring> assets;
1403 if (assets.contains(ob->asset_name)) {
1406 assets.insert(ob->asset_name);
1408 ob->asset_name.c_str(), ob->asset_name.length(), 0);
1409 manifest +=
string_printf(
"\"%s\":\"%08x\",", ob->asset_name.c_str(), hash_asset);
1411 manifest[manifest.size() - 1] =
'}';
list< Attribute > attributes
Attribute * find(ustring name) const
ImageHandle & data_voxel_for_write()
BoundBox transformed(const Transform *tfm) const
__forceinline bool valid() const
__forceinline float3 size() const
__forceinline bool intersects(const BoundBox &other)
__forceinline void grow(const float3 &pt)
device_vector< DecomposedTransform > object_motion
device_vector< Transform > object_motion_pass
device_vector< AttributeMap > attributes_map
device_vector< float > volume_step_size
device_vector< uint > object_prim_offset
device_vector< uint > object_flag
device_vector< KernelObject > objects
bool has_true_displacement() const
bool is_pointcloud() const
virtual PrimitiveType primitive_type() const =0
ImageMetaData metadata(Progress &progress)
void tag_update(Scene *scene, const uint32_t flag)
bool is_background_light() const
AttributeSet subd_attributes
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)
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)
NODE_DECLARE BoundBox bounds
bool usable_as_light() const
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)
float motion_time(const int step) const
bool has_shadow_linking() const
void adjust_volume_tfm(Transform &tfm)
array< Particle > particles
size_t num_points() const
PrimitiveType primitive_type() const override
void set_status(const string &status_, const string &substatus_="")
unique_ptr< ObjectManager > object_manager
MotionType need_motion() const
unique_ptr< LightManager > light_manager
unique_ptr< SceneUpdateStats > update_stats
void tag_shadow_catcher_modified()
@ MOTION_PASS_INTERACTIVE
unique_ptr_vector< ParticleSystem > particle_systems
unique_ptr< GeometryManager > geometry_manager
unique_ptr_vector< Object > objects
map< ustring, int > lightgroups
unique_ptr< VolumeManager > volume_manager
bool has_volume_attribute_dependency
EmissionSampling emission_sampling
bool has_volume_spatial_varying
T * alloc(const size_t width, const size_t height=0)
void free_if_need_realloc(bool force_free)
#define LIGHT_LINK_SET_MAX
#define OBJECT_MOTION_PASS_SIZE
#define LIGHT_LINK_MASK_ALL
#define SHADOW_CATCHER_OBJECT_VISIBILITY(is_shadow_catcher, visibility)
#define CCL_NAMESPACE_END
float hash_uint2_to_float(uint kx, uint ky)
#define assert(assertion)
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)
float reduce_min(float2 a)
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)
@ PATH_RAY_VISIBILITY_VOLUME_SCATTER
@ PATH_RAY_VISIBILITY_TRANSMIT
@ PATH_RAY_VISIBILITY_DIFFUSE
@ PATH_RAY_VISIBILITY_OBJECT_ALL
@ PATH_RAY_VISIBILITY_GLOSSY
@ SD_OBJECT_HAS_VOLUME_ATTRIBUTES
@ SD_OBJECT_HAS_CORNER_NORMALS
@ SD_OBJECT_INTERSECTS_VOLUME
@ SD_OBJECT_NEGATIVE_SCALE
@ 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
@ BVH_LAYOUT_MULTI_HIPRT_EMBREE
@ BVH_LAYOUT_MULTI_METAL_EMBREE
@ ATTR_STD_GSPLAT_RADIANCE_BASE
@ ATTR_STD_VOLUME_VELOCITY
@ ATTR_STD_GSPLAT_ROTATION
@ ATTR_STD_GSPLAT_RADIANCE_SPHERICAL_HARMONICS_REST
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
ccl_device_inline dual3 fabs(const ccl_private dual3 &a)
CCL_NAMESPACE_BEGIN ccl_device_inline float2 zero_float2()
ccl_device_inline float3 one_float3()
CCL_NAMESPACE_BEGIN ccl_device_inline float3 zero_float3()
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,...)
#define SOCKET_FLOAT(name, ui_name, default_value,...)
#define SOCKET_INT(name, ui_name, default_value,...)
#define SOCKET_NODE(name, ui_name, node_type,...)
#define SOCKET_TRANSFORM(name, ui_name, default_value,...)
#define SOCKET_UINT(name, ui_name, default_value,...)
#define NODE_DEFINE(structname)
#define SOCKET_COLOR(name, ui_name, default_value,...)
#define SOCKET_TRANSFORM_ARRAY(name, ui_name, default_value,...)
#define SOCKET_BOOLEAN(name, ui_name, default_value,...)
#define SOCKET_POINT2(name, ui_name, default_value,...)
#define SOCKET_STRING(name, ui_name, default_value,...)
#define SOCKET_UINT64(name, ui_name, default_value,...)
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,...)
uint64_t shadow_set_membership
float shadow_terminator_geometry_offset
uint attribute_map_offset
uint64_t light_set_membership
float shadow_terminator_shading_offset
static NodeType * add(const char *name, CreateFunc create, Type type=NONE, const NodeType *base=nullptr)
void set(const SocketType &input, bool value)
Node(const NodeType *type, ustring name=ustring())