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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2014-03-29 16:03:47 +0400
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2014-03-29 16:03:47 +0400
commit6020d0099039ed18c6a6cd330b68361123c85c1a (patch)
tree511c682800b981019f2eb5dfaf341238ea4882f8 /intern/cycles/render
parent8f33538fabe9b2485478b7ce0167c15396bdb355 (diff)
Cycles: add support for mesh deformation motion blur.
Diffstat (limited to 'intern/cycles/render')
-rw-r--r--intern/cycles/render/light.cpp8
-rw-r--r--intern/cycles/render/mesh.cpp14
-rw-r--r--intern/cycles/render/mesh.h3
-rw-r--r--intern/cycles/render/object.cpp42
4 files changed, 49 insertions, 18 deletions
diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp
index 29160e64082..cfc4f55ed5e 100644
--- a/intern/cycles/render/light.cpp
+++ b/intern/cycles/render/light.cpp
@@ -159,6 +159,10 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
if(!(object->visibility & (PATH_RAY_DIFFUSE|PATH_RAY_GLOSSY|PATH_RAY_TRANSMIT)))
continue;
+ /* skip motion blurred deforming meshes, not supported yet */
+ if(mesh->has_motion_blur())
+ continue;
+
/* skip if we have no emission shaders */
foreach(uint sindex, mesh->used_shaders) {
Shader *shader = scene->shaders[sindex];
@@ -201,6 +205,10 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
continue;
}
+ /* skip motion blurred deforming meshes, not supported yet */
+ if(mesh->has_motion_blur())
+ continue;
+
/* skip if we have no emission shaders */
foreach(uint sindex, mesh->used_shaders) {
Shader *shader = scene->shaders[sindex];
diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp
index 8e2cc97eba0..e216630b48c 100644
--- a/intern/cycles/render/mesh.cpp
+++ b/intern/cycles/render/mesh.cpp
@@ -81,6 +81,7 @@ Mesh::Mesh()
bounds = BoundBox::empty;
motion_steps = 3;
+ use_motion_blur = false;
bvh = NULL;
@@ -187,9 +188,9 @@ void Mesh::compute_bounds()
for(size_t i = 0; i < curve_keys_size; i++)
bnds.grow(float4_to_float3(curve_keys[i]), curve_keys[i].w);
-
+
Attribute *attr = attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
- if (attr) {
+ if (use_motion_blur && attr) {
size_t steps_size = verts.size() * (motion_steps - 1);
float3 *vert_steps = attr->data_float3();
@@ -216,7 +217,7 @@ void Mesh::compute_bounds()
for(size_t i = 0; i < curve_keys_size; i++)
bnds.grow_safe(float4_to_float3(curve_keys[i]), curve_keys[i].w);
- if (attr) {
+ if (use_motion_blur && attr) {
size_t steps_size = verts.size() * (motion_steps - 1);
float3 *vert_steps = attr->data_float3();
@@ -329,7 +330,7 @@ void Mesh::add_vertex_normals()
Attribute *attr_mP = attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
Attribute *attr_mN = attributes.find(ATTR_STD_MOTION_VERTEX_NORMAL);
- if(false && !attr_mN) {
+ if(has_motion_blur() && !attr_mN) {
/* create attribute */
attr_mN = attributes.add(ATTR_STD_MOTION_VERTEX_NORMAL);
@@ -533,6 +534,11 @@ void Mesh::tag_update(Scene *scene, bool rebuild)
scene->object_manager->need_update = true;
}
+bool Mesh::has_motion_blur() const
+{
+ return (use_motion_blur && attributes.find(ATTR_STD_MOTION_VERTEX_POSITION));
+}
+
/* Mesh Manager */
MeshManager::MeshManager()
diff --git a/intern/cycles/render/mesh.h b/intern/cycles/render/mesh.h
index 5ae8f1f6033..eec20acd3a9 100644
--- a/intern/cycles/render/mesh.h
+++ b/intern/cycles/render/mesh.h
@@ -90,6 +90,7 @@ public:
DisplacementMethod displacement_method;
uint motion_steps;
+ bool use_motion_blur;
/* Update Flags */
bool need_update;
@@ -127,6 +128,8 @@ public:
bool need_attribute(Scene *scene, ustring name);
void tag_update(Scene *scene, bool rebuild);
+
+ bool has_motion_blur() const;
};
/* Mesh Manager */
diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp
index e99ca323929..df03fa4a04c 100644
--- a/intern/cycles/render/object.cpp
+++ b/intern/cycles/render/object.cpp
@@ -89,17 +89,36 @@ void Object::apply_transform()
float3 c2 = transform_get_column(&tfm, 2);
float scalar = pow(fabsf(dot(cross(c0, c1), c2)), 1.0f/3.0f);
- /* apply to mesh vertices */
- for(size_t i = 0; i < mesh->verts.size(); i++)
- mesh->verts[i] = transform_point(&tfm, mesh->verts[i]);
+ /* triangles */
+ if(mesh->verts.size()) {
+ /* store matrix to transform later. when accessing these as attributes we
+ * do not want the transform to be applied for consistency between static
+ * and dynamic BVH, so we do it on packing. */
+ mesh->transform_normal = transform_transpose(transform_inverse(tfm));
+
+ /* apply to mesh vertices */
+ for(size_t i = 0; i < mesh->verts.size(); i++)
+ mesh->verts[i] = transform_point(&tfm, mesh->verts[i]);
+
+ Attribute *attr = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
+ if (attr) {
+ size_t steps_size = mesh->verts.size() * (mesh->motion_steps - 1);
+ float3 *vert_steps = attr->data_float3();
+
+ for (size_t i = 0; i < steps_size; i++)
+ vert_steps[i] = transform_point(&tfm, vert_steps[i]);
+ }
- Attribute *attr = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
- if (attr) {
- size_t steps_size = mesh->verts.size() * (mesh->motion_steps - 1);
- float3 *vert_steps = attr->data_float3();
+ Attribute *attr_N = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_NORMAL);
- for (size_t i = 0; i < steps_size; i++)
- vert_steps[i] = transform_point(&tfm, vert_steps[i]);
+ if(attr_N) {
+ Transform ntfm = mesh->transform_normal;
+ size_t steps_size = mesh->verts.size() * (mesh->motion_steps - 1);
+ float3 *normal_steps = attr_N->data_float3();
+
+ for (size_t i = 0; i < steps_size; i++)
+ normal_steps[i] = normalize(transform_direction(&ntfm, normal_steps[i]));
+ }
}
/* apply to curve keys */
@@ -121,11 +140,6 @@ void Object::apply_transform()
vert_steps[i] = transform_point(&tfm, vert_steps[i]);
}
- /* store matrix to transform later. when accessing these as attributes we
- * do not want the transform to be applied for consistency between static
- * and dynamic BVH, so we do it on packing. */
- mesh->transform_normal = transform_transpose(transform_inverse(tfm));
-
/* we keep normals pointing in same direction on negative scale, notify
* mesh about this in it (re)calculates normals */
if(transform_negative_scale(tfm))