2011-04-27 11:58:34 +00:00
|
|
|
/*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Copyright 2011-2013 Blender Foundation
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
2014-12-25 01:50:24 +00:00
|
|
|
* limitations under the License.
|
2011-04-27 11:58:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __OBJECT_H__
|
|
|
|
#define __OBJECT_H__
|
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 18:39:14 +00:00
|
|
|
#include "graph/node.h"
|
2020-11-04 10:17:38 +00:00
|
|
|
|
|
|
|
/* included as Object::set_particle_system defined through NODE_SOCKET_API does
|
|
|
|
* not select the right Node::set overload as it does not know that ParticleSystem
|
|
|
|
* is a Node */
|
|
|
|
#include "render/particles.h"
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 18:39:14 +00:00
|
|
|
#include "render/scene.h"
|
|
|
|
|
2018-11-09 10:54:24 +00:00
|
|
|
#include "util/util_array.h"
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 18:39:14 +00:00
|
|
|
#include "util/util_boundbox.h"
|
|
|
|
#include "util/util_param.h"
|
|
|
|
#include "util/util_thread.h"
|
2020-03-19 08:33:03 +00:00
|
|
|
#include "util/util_transform.h"
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 18:39:14 +00:00
|
|
|
#include "util/util_types.h"
|
2018-11-09 10:54:24 +00:00
|
|
|
#include "util/util_vector.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
class Device;
|
|
|
|
class DeviceScene;
|
2020-02-02 11:04:19 +00:00
|
|
|
class Geometry;
|
2014-02-25 17:29:11 +00:00
|
|
|
class ParticleSystem;
|
2011-04-27 11:58:34 +00:00
|
|
|
class Progress;
|
|
|
|
class Scene;
|
2011-05-03 18:29:11 +00:00
|
|
|
struct Transform;
|
2018-03-10 00:15:02 +00:00
|
|
|
struct UpdateObjectTransformState;
|
2018-11-29 01:06:30 +00:00
|
|
|
class ObjectManager;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
/* Object */
|
|
|
|
|
2016-05-07 19:44:17 +00:00
|
|
|
class Object : public Node {
|
2011-04-27 11:58:34 +00:00
|
|
|
public:
|
2017-03-06 13:16:45 +00:00
|
|
|
NODE_DECLARE
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2020-11-04 10:17:38 +00:00
|
|
|
NODE_SOCKET_API(Geometry *, geometry)
|
|
|
|
NODE_SOCKET_API(Transform, tfm)
|
2011-04-27 11:58:34 +00:00
|
|
|
BoundBox bounds;
|
2020-11-04 10:17:38 +00:00
|
|
|
NODE_SOCKET_API(uint, random_id)
|
|
|
|
NODE_SOCKET_API(int, pass_id)
|
|
|
|
NODE_SOCKET_API(float3, color)
|
|
|
|
NODE_SOCKET_API(ustring, asset_name)
|
2011-04-27 11:58:34 +00:00
|
|
|
vector<ParamValue> attributes;
|
2020-11-04 10:17:38 +00:00
|
|
|
NODE_SOCKET_API(uint, visibility)
|
|
|
|
NODE_SOCKET_API_ARRAY(array<Transform>, motion)
|
|
|
|
NODE_SOCKET_API(bool, hide_on_missing_motion)
|
|
|
|
NODE_SOCKET_API(bool, use_holdout)
|
|
|
|
NODE_SOCKET_API(bool, is_shadow_catcher)
|
|
|
|
NODE_SOCKET_API(float, shadow_terminator_offset)
|
|
|
|
|
|
|
|
NODE_SOCKET_API(float3, dupli_generated)
|
|
|
|
NODE_SOCKET_API(float2, dupli_uv)
|
|
|
|
|
|
|
|
NODE_SOCKET_API(ParticleSystem *, particle_system);
|
|
|
|
NODE_SOCKET_API(int, particle_index);
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
Object();
|
|
|
|
~Object();
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
void tag_update(Scene *scene);
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2014-03-29 12:03:46 +00:00
|
|
|
void compute_bounds(bool motion_blur);
|
2014-05-09 15:02:08 +00:00
|
|
|
void apply_transform(bool apply_to_motion);
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2018-03-08 03:04:52 +00:00
|
|
|
/* Convert between normalized -1..1 motion time and index
|
|
|
|
* in the motion array. */
|
|
|
|
bool use_motion() const;
|
|
|
|
float motion_time(int step) const;
|
|
|
|
int motion_step(float time) const;
|
|
|
|
void update_motion();
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2020-02-18 13:02:40 +00:00
|
|
|
/* Maximum number of motion steps supported (due to Embree). */
|
|
|
|
static const uint MAX_MOTION_STEPS = 129;
|
|
|
|
|
2016-06-06 07:15:34 +00:00
|
|
|
/* Check whether object is traceable and it worth adding it to
|
|
|
|
* kernel scene.
|
|
|
|
*/
|
2018-03-09 23:37:07 +00:00
|
|
|
bool is_traceable() const;
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2017-08-10 07:19:40 +00:00
|
|
|
/* Combine object's visibility with all possible internal run-time
|
|
|
|
* determined flags which denotes trace-time visibility.
|
|
|
|
*/
|
|
|
|
uint visibility_for_tracing() const;
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2018-11-29 01:06:30 +00:00
|
|
|
/* Returns the index that is used in the kernel for this object. */
|
|
|
|
int get_device_index() const;
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2020-03-07 13:38:52 +00:00
|
|
|
/* Compute step size from attributes, shaders, transforms. */
|
|
|
|
float compute_volume_step_size() const;
|
|
|
|
|
2018-11-29 01:06:30 +00:00
|
|
|
protected:
|
|
|
|
/* Specifies the position of the object in scene->objects and
|
|
|
|
* in the device vectors. Gets set in device_update. */
|
|
|
|
int index;
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2020-10-26 14:37:07 +00:00
|
|
|
/* Reference to the attribute map with object attributes,
|
|
|
|
* or 0 if none. Set in update_svm_attributes. */
|
|
|
|
size_t attr_map_offset;
|
|
|
|
|
2018-11-29 01:06:30 +00:00
|
|
|
friend class ObjectManager;
|
2020-10-26 14:37:07 +00:00
|
|
|
friend class GeometryManager;
|
2011-04-27 11:58:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Object Manager */
|
|
|
|
|
|
|
|
class ObjectManager {
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 14:01:26 +00:00
|
|
|
uint32_t update_flags;
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
public:
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 14:01:26 +00:00
|
|
|
enum : uint32_t {
|
|
|
|
PARTICLE_MODIFIED = (1 << 0),
|
|
|
|
GEOMETRY_MANAGER = (1 << 1),
|
|
|
|
MOTION_BLUR_MODIFIED = (1 << 2),
|
|
|
|
OBJECT_ADDED = (1 << 3),
|
|
|
|
OBJECT_REMOVED = (1 << 4),
|
|
|
|
OBJECT_MODIFIED = (1 << 5),
|
|
|
|
HOLDOUT_MODIFIED = (1 << 6),
|
|
|
|
|
|
|
|
/* tag everything in the manager for an update */
|
|
|
|
UPDATE_ALL = ~0u,
|
|
|
|
|
|
|
|
UPDATE_NONE = 0u,
|
|
|
|
};
|
|
|
|
|
2015-01-19 14:08:58 +00:00
|
|
|
bool need_flags_update;
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
ObjectManager();
|
|
|
|
~ObjectManager();
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress);
|
2018-01-15 10:45:16 +00:00
|
|
|
void device_update_transforms(DeviceScene *dscene, Scene *scene, Progress &progress);
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2015-06-01 18:59:23 +00:00
|
|
|
void device_update_flags(Device *device,
|
|
|
|
DeviceScene *dscene,
|
|
|
|
Scene *scene,
|
|
|
|
Progress &progress,
|
|
|
|
bool bounds_valid = true);
|
2017-11-05 16:40:36 +00:00
|
|
|
void device_update_mesh_offsets(Device *device, DeviceScene *dscene, Scene *scene);
|
2019-04-17 04:17:24 +00:00
|
|
|
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 14:01:26 +00:00
|
|
|
void device_free(Device *device, DeviceScene *dscene, bool force_free);
|
2019-04-17 04:17:24 +00:00
|
|
|
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 14:01:26 +00:00
|
|
|
void tag_update(Scene *scene, uint32_t flag);
|
|
|
|
|
|
|
|
bool need_update() const;
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2018-03-10 00:15:02 +00:00
|
|
|
void apply_static_transforms(DeviceScene *dscene, Scene *scene, Progress &progress);
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2018-11-07 03:05:47 +00:00
|
|
|
string get_cryptomatte_objects(Scene *scene);
|
|
|
|
string get_cryptomatte_assets(Scene *scene);
|
2019-04-17 04:17:24 +00:00
|
|
|
|
2016-04-20 16:12:26 +00:00
|
|
|
protected:
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 14:01:26 +00:00
|
|
|
void device_update_object_transform(UpdateObjectTransformState *state,
|
|
|
|
Object *ob,
|
|
|
|
bool update_all);
|
2018-02-05 09:01:00 +00:00
|
|
|
void device_update_object_transform_task(UpdateObjectTransformState *state);
|
2016-04-20 16:12:26 +00:00
|
|
|
bool device_update_object_transform_pop_work(UpdateObjectTransformState *state,
|
|
|
|
int *start_index,
|
|
|
|
int *num_objects);
|
2011-04-27 11:58:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|
|
|
|
#endif /* __OBJECT_H__ */
|