diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2014-03-29 16:03:46 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2014-03-29 16:03:46 +0400 |
commit | 99f59930885ed69890967f8864a3aa0626249d86 (patch) | |
tree | b6f8dcc40c294077d585639e701f7fdf9b6c0dcb /intern/cycles/kernel | |
parent | 934767cf7f51ae82224138de2ffcafe7bae2b8fa (diff) |
Cycles code refactor: improve vertex motion attribute storage and export.
This now supports multiple steps and subframe sampling of motion.
There is one difference for object and camera transform motion blur. It still
only supports two steps there, but the transforms are now sampled at subframe
times instead of the previous and next frame and then interpolated/extrapolated.
This will give different render results in some cases but it's more accurate.
Part of the code is from the summer of code project by Gavin Howard, but it has
been significantly rewritten and extended.
Diffstat (limited to 'intern/cycles/kernel')
-rw-r--r-- | intern/cycles/kernel/geom/geom_object.h | 15 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_camera.h | 2 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_primitive.h | 22 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_types.h | 3 |
4 files changed, 31 insertions, 11 deletions
diff --git a/intern/cycles/kernel/geom/geom_object.h b/intern/cycles/kernel/geom/geom_object.h index 3646615b9f6..b1106c25fd7 100644 --- a/intern/cycles/kernel/geom/geom_object.h +++ b/intern/cycles/kernel/geom/geom_object.h @@ -230,6 +230,21 @@ ccl_device_inline float3 object_dupli_uv(KernelGlobals *kg, int object) return make_float3(f.x, f.y, 0.0f); } +ccl_device_inline void object_motion_info(KernelGlobals *kg, int object, int *numsteps, int *numverts, int *numkeys) +{ + int offset = object*OBJECT_SIZE + OBJECT_DUPLI; + + if(numkeys) { + float4 f = kernel_tex_fetch(__objects, offset); + *numkeys = __float_as_int(f.w); + } + + float4 f = kernel_tex_fetch(__objects, offset + 1); + if(numsteps) + *numsteps = __float_as_int(f.z); + if(numverts) + *numverts = __float_as_int(f.w); +} ccl_device int shader_pass_id(KernelGlobals *kg, ShaderData *sd) { diff --git a/intern/cycles/kernel/kernel_camera.h b/intern/cycles/kernel/kernel_camera.h index 887b1afddd4..fe995bbb594 100644 --- a/intern/cycles/kernel/kernel_camera.h +++ b/intern/cycles/kernel/kernel_camera.h @@ -229,7 +229,7 @@ ccl_device void camera_sample(KernelGlobals *kg, int x, int y, float filter_u, f if(kernel_data.cam.shuttertime == -1.0f) ray->time = TIME_INVALID; else - ray->time = 0.5f + 0.5f*(time - 0.5f)*kernel_data.cam.shuttertime; + ray->time = time; #endif /* sample */ diff --git a/intern/cycles/kernel/kernel_primitive.h b/intern/cycles/kernel/kernel_primitive.h index f9efdd2cf56..af5faf37c3f 100644 --- a/intern/cycles/kernel/kernel_primitive.h +++ b/intern/cycles/kernel/kernel_primitive.h @@ -161,14 +161,20 @@ ccl_device float4 primitive_motion_vector(KernelGlobals *kg, ShaderData *sd) float3 motion_pre = sd->P, motion_post = sd->P; /* deformation motion */ - AttributeElement elem_pre, elem_post; - int offset_pre = find_attribute(kg, sd, ATTR_STD_MOTION_PRE, &elem_pre); - int offset_post = find_attribute(kg, sd, ATTR_STD_MOTION_POST, &elem_post); - - if(offset_pre != ATTR_STD_NOT_FOUND) - motion_pre = primitive_attribute_float3(kg, sd, elem_pre, offset_pre, NULL, NULL); - if(offset_post != ATTR_STD_NOT_FOUND) - motion_post = primitive_attribute_float3(kg, sd, elem_post, offset_post, NULL, NULL); + AttributeElement elem; + int offset = find_attribute(kg, sd, ATTR_STD_MOTION_VERTEX_POSITION, &elem); + + if(offset != ATTR_STD_NOT_FOUND) { + /* get motion info */ + int numverts, numkeys; + object_motion_info(kg, sd->object, NULL, &numverts, &numkeys); + + /* lookup attributes */ + int offset_next = (sd->type & PRIMITIVE_ALL_TRIANGLE)? offset + numverts: offset + numkeys; + + motion_pre = primitive_attribute_float3(kg, sd, elem, offset, NULL, NULL); + motion_post = primitive_attribute_float3(kg, sd, elem, offset_next, NULL, NULL); + } /* object motion. note that depending on the mesh having motion vectors, this * transformation was set match the world/object space of motion_pre/post */ diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index b260a3d11ac..f708f019912 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -470,8 +470,7 @@ typedef enum AttributeStandard { ATTR_STD_GENERATED_TRANSFORM, ATTR_STD_POSITION_UNDEFORMED, ATTR_STD_POSITION_UNDISPLACED, - ATTR_STD_MOTION_PRE, - ATTR_STD_MOTION_POST, + ATTR_STD_MOTION_VERTEX_POSITION, ATTR_STD_PARTICLE, ATTR_STD_CURVE_INTERCEPT, ATTR_STD_PTEX_FACE_ID, |