[Bf-blender-cvs] [c8baf8cb39a] soc-2018-cycles-volumes: Updates to OpenVDB import and volume motion blur.
Geraldine Chua
noreply at git.blender.org
Fri Aug 10 07:31:54 CEST 2018
Commit: c8baf8cb39a427e94c4a8c88be2ee2ddd41bc88d
Author: Geraldine Chua
Date: Wed Aug 8 11:27:11 2018 +0800
Branches: soc-2018-cycles-volumes
https://developer.blender.org/rBc8baf8cb39a427e94c4a8c88be2ee2ddd41bc88d
Updates to OpenVDB import and volume motion blur.
* Separated option for Volume Motion Blur in object UI. Unlike deformation motion, it is disabled by default.
* Added multiple frame import and preview simplying for imported VDBs.
* Fixed a couple of bugs with VDBs in the viewport.
===================================================================
M intern/cycles/blender/addon/properties.py
M intern/cycles/blender/addon/ui.py
M intern/cycles/blender/blender_mesh.cpp
M intern/cycles/blender/blender_object.cpp
M intern/cycles/blender/blender_util.h
M intern/cycles/render/mesh.cpp
M intern/cycles/render/mesh.h
M intern/openvdb/intern/openvdb_dense_convert.h
M intern/openvdb/openvdb_capi.cc
M intern/openvdb/openvdb_capi.h
M release/scripts/startup/bl_ui/properties_physics_smoke.py
M source/blender/blenkernel/BKE_pointcache.h
M source/blender/blenkernel/intern/pointcache.c
M source/blender/editors/io/io_openvdb.c
M source/blender/makesdna/DNA_smoke_types.h
M source/blender/makesrna/intern/rna_smoke.c
===================================================================
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index 1141973efd3..1b911747899 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -1083,10 +1083,16 @@ class CyclesObjectSettings(bpy.types.PropertyGroup):
cls.use_deform_motion = BoolProperty(
name="Use Deformation Motion",
- description="Use deformation motion blur for this object. If object is a volume, use volume motion blur",
+ description="Use deformation motion blur for this object",
default=True,
)
+ cls.use_volume_motion = BoolProperty(
+ name="Use Volume Motion",
+ description="Use volume motion blur for this object",
+ default=False,
+ )
+
cls.motion_steps = IntProperty(
name="Motion Steps",
description="Control accuracy of motion blur, more steps gives more memory usage (actual number of steps is 2^(steps - 1))",
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index 707f8756f6f..101f8f45b51 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -845,6 +845,10 @@ class CYCLES_OBJECT_PT_motion_blur(CyclesButtonsPanel, Panel):
row.prop(cob, "use_deform_motion", text="Deformation")
row.prop(cob, "motion_steps", text="Steps")
+ row = layout.row()
+ if ob.type != 'CAMERA':
+ row.prop(cob, "use_volume_motion", text="Volume")
+
class CYCLES_OBJECT_PT_cycles_settings(CyclesButtonsPanel, Panel):
bl_label = "Cycles Settings"
diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp
index 7486eba2d48..0281ef0a249 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -31,10 +31,6 @@
#include "util/util_logging.h"
#include "util/util_math.h"
-#ifdef WITH_OPENVDB
-#include "render/openvdb.h"
-#endif
-
#include "mikktspace.h"
CCL_NAMESPACE_BEGIN
@@ -376,23 +372,15 @@ static void create_mesh_volume_attributes(Scene *scene,
return;
string filename;
- void *builtin_data;
-
- if(b_domain.use_volume_file()) {
- BL::ID b_id = b_ob.data();
- filename = blender_absolute_path(b_data, b_id,
- b_domain.volume_filepath());
+ void *builtin_data = NULL;
- if(string_endswith(filename, ".vdb") &&
- !scene->params.intialized_openvdb)
- {
- openvdb_initialize();
- scene->params.intialized_openvdb = true;
+ if(volume_get_frame_file(b_data, b_ob, b_domain, (int)frame, filename)) {
+ if(string_endswith(filename, ".vdb")) {
+ init_openvdb_in_scene(scene->params.intialized_openvdb);
}
-
- builtin_data = NULL;
}
else {
+ filename = string();
builtin_data = b_ob.ptr.data;
}
@@ -408,7 +396,7 @@ static void create_mesh_volume_attributes(Scene *scene,
create_mesh_volume_attribute(mesh, scene->image_manager, ATTR_STD_VOLUME_HEAT, filename, builtin_data, frame);
if(mesh->need_attribute(scene, ATTR_STD_VOLUME_TEMPERATURE))
create_mesh_volume_attribute(mesh, scene->image_manager, ATTR_STD_VOLUME_TEMPERATURE, filename, builtin_data, frame);
- if(mesh->need_attribute(scene, ATTR_STD_VOLUME_VELOCITY) || scene->need_motion() == Scene::MOTION_BLUR)
+ if(mesh->need_attribute(scene, ATTR_STD_VOLUME_VELOCITY) || mesh->use_volume_motion_blur)
create_mesh_volume_attribute(mesh, scene->image_manager, ATTR_STD_VOLUME_VELOCITY, filename, builtin_data, frame);
}
diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp
index 077ceb4ebef..13fd9bfc393 100644
--- a/intern/cycles/blender/blender_object.cpp
+++ b/intern/cycles/blender/blender_object.cpp
@@ -384,16 +384,23 @@ Object *BlenderSync::sync_object(BL::Object& b_parent,
Scene::MotionType need_motion = scene->need_motion();
if(need_motion != Scene::MOTION_NONE && object->mesh) {
Mesh *mesh = object->mesh;
- mesh->use_motion_blur = false;
mesh->motion_steps = 0;
+ mesh->use_motion_blur = false;
+ mesh->use_volume_motion_blur = false;
uint motion_steps;
if(scene->need_motion() == Scene::MOTION_BLUR) {
motion_steps = object_motion_steps(b_parent, b_ob);
- if(motion_steps && object_use_deform_motion(b_parent, b_ob)) {
+ bool deform_motion = object_use_deform_motion(b_parent, b_ob);
+ bool volume_motion = object_use_volume_motion(b_parent, b_ob, b_data,
+ (int)b_scene.frame_current(),
+ scene->params.intialized_openvdb);
+
+ if(motion_steps && (deform_motion || volume_motion)) {
mesh->motion_steps = motion_steps;
- mesh->use_motion_blur = true;
+ mesh->use_motion_blur = deform_motion;
+ mesh->use_volume_motion_blur = volume_motion;
}
}
else {
diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h
index 85bff8f8323..7f737fe6214 100644
--- a/intern/cycles/blender/blender_util.h
+++ b/intern/cycles/blender/blender_util.h
@@ -18,6 +18,9 @@
#define __BLENDER_UTIL_H__
#include "render/mesh.h"
+#ifdef WITH_OPENVDB
+#include "render/openvdb.h"
+#endif
#include "util/util_algorithm.h"
#include "util/util_map.h"
@@ -36,6 +39,7 @@ void BKE_image_user_frame_calc(void *iuser, int cfra, int fieldnr);
void BKE_image_user_file_path(void *iuser, void *ima, char *path);
unsigned char *BKE_image_get_pixels_for_frame(void *image, int frame);
float *BKE_image_get_float_pixels_for_frame(void *image, int frame);
+void BKE_ptcache_volume_extern_find_frame(const char *input, char *output, const int cfra, const short multi_import);
}
CCL_NAMESPACE_BEGIN
@@ -605,6 +609,72 @@ static inline Mesh::SubdivisionType object_subdivision_type(BL::Object& b_ob, bo
return Mesh::SUBDIVISION_NONE;
}
+static inline void init_openvdb_in_scene(bool& initialized)
+{
+ if(!initialized) {
+ openvdb_initialize();
+ initialized = true;
+ }
+}
+
+static inline bool volume_get_frame_file(BL::BlendData& b_data,
+ BL::Object& b_ob,
+ BL::SmokeDomainSettings& b_domain,
+ const int& cfra,
+ string& filename)
+{
+ if(b_domain.volume_filepath().empty()) {
+ return false;
+ }
+
+ char output[1024];
+ BKE_ptcache_volume_extern_find_frame(b_domain.volume_filepath().c_str(),
+ output, cfra, b_domain.multi_import());
+
+ BL::ID b_id = b_ob.data();
+ filename = blender_absolute_path(b_data, b_id, string(output));
+
+ return true;
+}
+
+static inline bool object_use_volume_motion(BL::Object& b_parent,
+ BL::Object& b_ob,
+ BL::BlendData& b_data,
+ const int& cfra,
+ bool& initialized_openvdb)
+{
+ BL::SmokeDomainSettings b_domain = object_smoke_domain_find(b_ob);
+ if(!b_domain) {
+ return false;
+ }
+
+ /* For imported volumes, the file must have a velocity grid. */
+ string filename;
+ if(volume_get_frame_file(b_data, b_ob, b_domain, cfra, filename)) {
+ if(string_endswith(filename, ".vdb")) {
+ init_openvdb_in_scene(initialized_openvdb);
+ if(!openvdb_has_grid(filename, "velocity")) {
+ return false;
+ }
+ }
+ }
+
+ PointerRNA cobject = RNA_pointer_get(&b_ob.ptr, "cycles");
+ bool use_volume_motion = get_boolean(cobject, "use_volume_motion");
+
+ /* If motion blur is enabled for the object we also check
+ * whether it's enabled for the parent object as well.
+ *
+ * This way we can control motion blur from the dupligroup
+ * duplicator much easier.
+ */
+ if(use_volume_motion && b_parent.ptr.data != b_ob.ptr.data) {
+ PointerRNA parent_cobject = RNA_pointer_get(&b_parent.ptr, "cycles");
+ use_volume_motion &= get_boolean(parent_cobject, "use_volume_motion");
+ }
+ return use_volume_motion;
+}
+
/* ID Map
*
* Utility class to keep in sync with blender data.
diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp
index 570dbf083ff..f74e238f3c5 100644
--- a/intern/cycles/render/mesh.cpp
+++ b/intern/cycles/render/mesh.cpp
@@ -1545,7 +1545,7 @@ void MeshManager::device_update_attributes(Device *device, DeviceScene *dscene,
}
/* motion blur for volumes */
- if(mesh->use_motion_blur && mesh->motion_steps > 1 && mesh->has_volume)
+ if(mesh->use_volume_motion_blur)
{
mesh_attributes[i].add(ATTR_STD_VOLUME_VELOCITY);
}
diff --git a/intern/cycles/render/mesh.h b/intern/cycles/render/mesh.h
index e370f8a2021..259ae91ecfe 100644
--- a/intern/cycles/render/mesh.h
+++ b/intern/cycles/render/mesh.h
@@ -232,7 +232,8 @@ public:
PackedPatchTable *patch_table;
uint motion_steps;
- bool use_motion_blur;
+ bool use_motion_blur; /* Motion blur for mesh itself. */
+ bool use_volume_motion_blur; /* Motion blur for volume data within mesh. */
/* Update Flags */
bool need_update;
diff --git a/intern/openvdb/intern/openvdb_dense_convert.h b/intern/openvdb/intern/openvdb_dense_convert.h
index 8f5d7b271bc..1a880fda2c2 100644
--- a/intern/openvdb/intern/openvdb_dense_convert.h
+++ b/intern/openvdb/intern/openvdb_dense_convert.h
@@ -124,11 +124,11 @@ template <typename GridType, typename GridDataType, typename DataType>
void OpenVDB_import_grid(
OpenVDBReader *reader,
const char *name,
- typename GridType::Ptr *grid_ptr,
DataType **data,
- const int res[3],
+ const int raw_res[3],
const int min_bound[3],
const int channels,
+ const int sample_level,
const bool weave)
{
using namespace openvdb;
@@ -138,6 +138,12 @@ void OpenVDB_import_grid(
* Normal data is an array of pointers while weave data is a pointer to a
* flat T array. */
+ int remainder[3], res[3];
+ for(int i = 0; i < 3; ++i) {
+ remainder[i] = res[i] % CUBE_SIZE;
+ res[i] = raw_res[i] / sample_level + (raw_res[i] % sample_level != 0);
+ }
+
i
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list