74 if (!preserve_shaders) {
86 return (motion_steps > 1) ? 2.0f *
step / (motion_steps - 1) - 1.0f : 0.0f;
91 if (motion_steps > 1) {
96 if (step_time == time) {
101 if (
step != motion_steps / 2) {
132 for (
Node *node : used_shaders) {
154 for (
Node *node : used_shaders) {
186 og->object_name_map.clear();
187 og->object_names.clear();
192 og->object_name_map[
object->name] =
i;
193 og->object_names.push_back(object->
name);
211 switch (kernel_type) {
261 size_t vert_size = 0;
264 size_t curve_size = 0;
265 size_t curve_key_size = 0;
266 size_t curve_segment_size = 0;
268 size_t point_size = 0;
270 size_t face_size = 0;
271 size_t corner_size = 0;
274 bool prim_offset_changed =
false;
277 Mesh *mesh =
static_cast<Mesh *
>(geom);
279 prim_offset_changed = (mesh->
prim_offset != tri_size);
287 vert_size += mesh->verts.size();
291 corner_size += mesh->subd_face_corners.size();
294 Hair *hair =
static_cast<Hair *
>(geom);
302 curve_key_size += hair->get_curve_keys().size();
308 prim_offset_changed = (pointcloud->
prim_offset != point_size);
314 if (prim_offset_changed) {
336 uint32_t device_update_flags = 0;
340 scene->
update_stats->geometry.times.add_entry({
"device_update_preprocess", time});
344 progress.set_status(
"Updating Meshes Flags");
347 bool volume_images_updated =
false;
355 Mesh *mesh =
static_cast<Mesh *
>(geom);
359 for (
Node *node : geom->get_used_shaders()) {
374 Mesh *mesh =
static_cast<Mesh *
>(geom);
386 Mesh *mesh =
static_cast<Mesh *
>(geom);
396 Mesh *mesh =
static_cast<Mesh *
>(geom);
397 mesh->tag_verts_modified();
398 mesh->tag_subd_dicing_rate_modified();
399 mesh->tag_subd_max_level_modified();
400 mesh->tag_subd_objecttoworld_modified();
419 if (!volume_images_updated) {
420 progress.set_status(
"Updating Meshes Volume Bounds");
422 volume_images_updated =
true;
434 Hair *hair =
static_cast<Hair *
>(geom);
446 Mesh *mesh =
static_cast<Mesh *
>(geom);
511 dscene->
points.tag_realloc();
575 dscene->
points.tag_modified();
586 progress.set_status(
"Updating Displacement Images");
589 set<int> bump_images;
591 bool has_osl_node =
false;
598 bool need_shadow_transparency =
false;
600 Hair *hair =
static_cast<Hair *
>(geom);
604 for (
Node *node : geom->get_used_shaders()) {
608 if (!is_true_displacement && !need_shadow_transparency) {
625 bump_images.insert(slot);
637 OSLShaderManager::osl_image_slots(device, image_manager, bump_images);
641 for (
const int slot : bump_images) {
642 pool.
push([image_manager, device, scene, slot, &
progress] {
651 progress.set_status(
"Updating Volume Images");
654 set<int> volume_images;
672 volume_images.insert(slot);
678 for (
const int slot : volume_images) {
679 pool.
push([image_manager, device, scene, slot, &
progress] {
697 bool true_displacement_used =
false;
698 bool curve_shadow_transparency_used =
false;
699 size_t num_tessellation = 0;
704 scene->
update_stats->geometry.times.add_entry({
"device_update (normals)", time});
711 Mesh *mesh =
static_cast<Mesh *
>(geom);
718#ifdef WITH_OPENSUBDIV
731 true_displacement_used =
true;
735 Hair *hair =
static_cast<Hair *
>(geom);
737 curve_shadow_transparency_used =
true;
756 {(num_tessellation) ?
"device_update (tessellation and tangents)" :
757 "device_update (tangents)",
763 if (num_tessellation) {
764 dicing_camera->set_screen_size(dicing_camera->get_full_width(),
765 dicing_camera->get_full_height());
766 dicing_camera->update(scene);
775 Mesh *mesh =
static_cast<Mesh *
>(geom);
778 string msg =
"Tessellating ";
779 if (mesh->
name.empty()) {
784 "%s %u/%u", mesh->
name.c_str(), (
uint)(
i + 1), (
uint)num_tessellation);
787 progress.set_status(
"Updating Mesh", msg);
790 subd_params.
dicing_rate = mesh->get_subd_dicing_rate();
791 subd_params.
max_level = mesh->get_subd_max_level();
793 subd_params.
camera = dicing_camera;
815 if (true_displacement_used || curve_shadow_transparency_used) {
819 {
"device_update (displacement: load images)", time});
832 if (true_displacement_used || curve_shadow_transparency_used) {
836 {
"device_update (displacement: copy meshes to device)", time});
851 {
"device_update (apply static transforms)", time});
855 progress.set_status(
"Updating Objects",
"Applying Static Transformations");
866 scene->
update_stats->geometry.times.add_entry({
"device_update (attributes)", time});
876 bool displacement_done =
false;
877 bool curve_shadow_transparency_done =
false;
885 scene->
update_stats->geometry.times.add_entry({
"device_update (displacement)", time});
892 Mesh *mesh =
static_cast<Mesh *
>(geom);
894 displacement_done =
true;
898 Hair *hair =
static_cast<Hair *
>(geom);
900 curve_shadow_transparency_done =
true;
916 if (displacement_done || curve_shadow_transparency_done) {
920 {
"device_update (displacement: attributes)", time});
936 bool need_update_scene_bvh = (scene->
bvh ==
nullptr ||
941 scene->
update_stats->geometry.times.add_entry({
"device_update (build object BVHs)", time});
955 need_update_scene_bvh =
true;
962 if (use_multithreaded_build) {
963 bvh_task_pool_.push([geom, device, dscene, scene, &
progress,
i, &num_bvh] {
974 bvh_task_pool_.wait_work(&summary);
991 scene->
update_stats->geometry.times.add_entry({
"device_update (compute bounds)", time});
995 object->compute_bounds(motion_blur);
1003 if (need_update_scene_bvh) {
1006 scene->
update_stats->geometry.times.add_entry({
"device_update (build scene BVH)", time});
1024 {
"device_update (copy meshes to device)", time});
1040 Mesh *mesh =
static_cast<Mesh *
>(geom);
1062 dscene->
points.clear_modified();
1087 dscene->
curve_keys.free_if_need_realloc(force_free);
1089 dscene->
points.free_if_need_realloc(force_free);
1105 og->object_name_map.clear();
1106 og->object_names.clear();
1115 update_flags |=
flag;
list< Attribute > attributes
bool modified(AttrKernelDataType kernel_type) const
static BVHLayout best_bvh_layout(BVHLayout requested_layout, BVHLayoutMask supported_layouts)
bool contains_device_type(const DeviceType type) const
device_vector< uint > points_shader
device_vector< float2 > prim_time
device_vector< float4 > points
device_vector< uint > prim_visibility
device_vector< float4 > attributes_float4
device_vector< KernelCurveSegment > curve_segments
device_vector< float2 > attributes_float2
device_vector< AttributeMap > attributes_map
device_vector< KernelCurve > curves
device_vector< packed_uint3 > tri_vindex
device_vector< int > object_node
device_vector< packed_float3 > attributes_float3
device_vector< int > prim_object
device_vector< float4 > curve_keys
device_vector< packed_float3 > tri_vnormal
device_vector< int4 > bvh_leaf_nodes
device_vector< uint > tri_shader
device_vector< packed_float3 > tri_verts
device_vector< float > attributes_float
device_vector< int > prim_type
device_vector< int4 > bvh_nodes
device_vector< int > prim_index
device_vector< uchar4 > attributes_uchar4
virtual void const_copy_to(const char *name, void *host, const size_t size)=0
virtual BVHLayoutMask get_bvh_layout_mask(const uint kernel_features) const =0
virtual OSLGlobals * get_cpu_osl_memory()
void device_update_displacement_images(Device *device, Scene *scene, Progress &progress)
void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress)
void geom_calc_offset(Scene *scene, BVHLayout bvh_layout)
void tag_update(Scene *scene, const uint32_t flag)
void device_update_attributes(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress)
void update_osl_globals(Device *device, Scene *scene)
void create_volume_mesh(const Scene *scene, Volume *volume, Progress &progress)
void device_free(Device *device, DeviceScene *dscene, bool force_free)
void device_update_bvh(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress)
void collect_statistics(const Scene *scene, RenderStats *stats)
void device_update_mesh(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress)
void device_update_preprocess(Device *device, Scene *scene, Progress &progress)
void device_update_volume_images(Device *device, Scene *scene, Progress &progress)
bool displace(Device *device, Scene *scene, Mesh *mesh, Progress &progress)
Transform transform_normal
int motion_step(const float time) const
bool need_update_bvh_for_offset
bool has_true_displacement() const
bool need_build_bvh(BVHLayout layout) const
bool is_pointcloud() const
bool is_instanced() const
void compute_bvh(Device *device, DeviceScene *dscene, SceneParams *params, Progress *progress, const size_t n, size_t total)
virtual bool has_motion_blur() const
void tag_update(Scene *scene, bool rebuild)
Geometry(const NodeType *node_type, const Type type)
bool transform_negative_scaled
float motion_time(const int step) const
virtual void clear(bool preserve_shaders=false)
bool need_shadow_transparency()
size_t curve_segment_offset
size_t num_curves() const
bool update_shadow_transparency(Device *device, Scene *scene, Progress &progress)
size_t num_segments() const
CurveShapeType curve_shape
VDBImageLoader * vdb_loader() const
int num_svm_slots() const
int svm_slot(const int slot_index=0) const
void device_update_slot(Device *device, Scene *scene, const size_t slot, Progress &progress)
void add_entry(const NamedSizeEntry &entry)
CurveShapeType hair_shape
ShaderNodeSpecialType special_type
bool need_update_attribute
bool need_update_displacement
EmissionSampling emission_sampling
NODE_DECLARE unique_ptr< ShaderGraph > graph
void free_if_need_realloc(bool force_free)
#define CCL_NAMESPACE_END
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
@ ATTR_STD_MOTION_VERTEX_POSITION
@ BVH_LAYOUT_MULTI_HIPRT_EMBREE
@ BVH_LAYOUT_MULTI_EMBREEGPU
@ BVH_LAYOUT_MULTI_METAL_EMBREE
@ BVH_LAYOUT_MULTI_EMBREEGPU_EMBREE
@ BVH_LAYOUT_MULTI_OPTIX_EMBREE
#define SOCKET_NODE_ARRAY(name, ui_name, node_type,...)
#define SOCKET_UINT(name, ui_name, default_value,...)
#define SOCKET_BOOLEAN(name, ui_name, default_value,...)
#define NODE_ABSTRACT_DEFINE(structname)
KernelBVHLayout BVHLayout
static void update_device_flags_attribute(uint32_t &device_update_flags, const AttributeSet &attributes)
static void update_attribute_realloc_flags(uint32_t &device_update_flags, const AttributeSet &attributes)
@ DEVICE_MESH_DATA_NEEDS_REALLOC
@ DEVICE_POINT_DATA_MODIFIED
@ DEVICE_POINT_DATA_NEEDS_REALLOC
@ ATTR_FLOAT4_NEEDS_REALLOC
@ ATTR_UCHAR4_NEEDS_REALLOC
@ ATTR_FLOAT2_NEEDS_REALLOC
@ DEVICE_MESH_DATA_MODIFIED
@ DEVICE_CURVE_DATA_MODIFIED
@ ATTR_FLOAT_NEEDS_REALLOC
@ DEVICE_CURVE_DATA_NEEDS_REALLOC
@ ATTR_FLOAT3_NEEDS_REALLOC
@ SHADER_SPECIAL_TYPE_IMAGE_SLOT
@ SHADER_SPECIAL_TYPE_OSL
CCL_NAMESPACE_BEGIN string string_printf(const char *format,...)
static AttrKernelDataType kernel_type(const Attribute &attr)
ImageHandle & data_voxel()
void tessellate(SubdParams ¶ms)
size_t get_num_subd_faces() const
void update_tangents(Scene *scene)
void add_vertex_normals()
AttributeSet subd_attributes
@ SUBDIVISION_CATMULL_CLARK
size_t num_triangles() const
void update_generated(Scene *scene)
static NodeType * add(const char *name, CreateFunc create, Type type=NONE, const NodeType *base=nullptr)
void dereference_all_used_nodes()
size_t get_total_size_in_bytes() const
Node(const NodeType *type, ustring name=ustring())
size_t num_points() const
unique_ptr< ObjectManager > object_manager
MotionType need_motion() const
unique_ptr< LightManager > light_manager
unique_ptr_vector< Geometry > geometry
unique_ptr< SceneUpdateStats > update_stats
unique_ptr_vector< Shader > shaders
unique_ptr< GeometryManager > geometry_manager
unique_ptr_vector< Object > objects
unique_ptr< ImageManager > image_manager
string full_report() const
void push(TaskRunFunction &&task)
void wait_work(Summary *stats=nullptr)