Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKévin Dietrich <kevin.dietrich@mailoo.org>2022-01-04 03:58:34 +0300
committerKévin Dietrich <kevin.dietrich@mailoo.org>2022-01-05 16:17:57 +0300
commit4c3f52e7dc868471393cab76619b1187a654bc43 (patch)
treec387d9db194a4632f0c5b23b9029f27c749a9ab2 /intern/cycles/blender/util.h
parentb1bd0f8ffdaf5e5df3038ae688a7b4eb8d10ba6d (diff)
Cycles: support rendering PointCloud motion blur from attribute
This adds support to render PointCloud motion blur from a standard "velocity" attribute. This implementation is similar to that of the Mesh geometry, and perhaps some code could be deduplicated through a more generic API. `mesh_need_motion_attribute` was renamed `object_need_motion_attribute` as it does not really require a mesh and moved to `util.h` so that it can be shared. This fixes T94622. Reviewed By: brecht Maniphest Tasks: T94622 Differential Revision: https://developer.blender.org/D13719
Diffstat (limited to 'intern/cycles/blender/util.h')
-rw-r--r--intern/cycles/blender/util.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/intern/cycles/blender/util.h b/intern/cycles/blender/util.h
index 6c396d39614..ae9cdfd4f58 100644
--- a/intern/cycles/blender/util.h
+++ b/intern/cycles/blender/util.h
@@ -18,6 +18,7 @@
#define __BLENDER_UTIL_H__
#include "scene/mesh.h"
+#include "scene/scene.h"
#include "util/algorithm.h"
#include "util/array.h"
@@ -670,6 +671,40 @@ static inline uint object_ray_visibility(BL::Object &b_ob)
return flag;
}
+/* Check whether some of "built-in" motion-related attributes are needed to be exported (includes
+ * things like velocity from cache modifier, fluid simulation).
+ *
+ * NOTE: This code is run prior to object motion blur initialization. so can not access properties
+ * set by `sync_object_motion_init()`. */
+static bool object_need_motion_attribute(BObjectInfo &b_ob_info, Scene *scene)
+{
+ const Scene::MotionType need_motion = scene->need_motion();
+ if (need_motion == Scene::MOTION_NONE) {
+ /* Simple case: neither motion pass nor motion blur is needed, no need in the motion related
+ * attributes. */
+ return false;
+ }
+
+ if (need_motion == Scene::MOTION_BLUR) {
+ /* A bit tricky and implicit case:
+ * - Motion blur is enabled in the scene, which implies specific number of time steps for
+ * objects.
+ * - If the object has motion blur disabled on it, it will have 0 time steps.
+ * - Motion attribute expects non-zero time steps.
+ *
+ * Avoid adding motion attributes if the motion blur will enforce 0 motion steps. */
+ PointerRNA cobject = RNA_pointer_get(&b_ob_info.real_object.ptr, "cycles");
+ const bool use_motion = get_boolean(cobject, "use_motion_blur");
+ if (!use_motion) {
+ return false;
+ }
+ }
+
+ /* Motion pass which implies 3 motion steps, or motion blur which is not disabled on object
+ * level. */
+ return true;
+}
+
class EdgeMap {
public:
EdgeMap()