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:
Diffstat (limited to 'intern/cycles/kernel/geom/geom_volume.h')
-rw-r--r--intern/cycles/kernel/geom/geom_volume.h36
1 files changed, 32 insertions, 4 deletions
diff --git a/intern/cycles/kernel/geom/geom_volume.h b/intern/cycles/kernel/geom/geom_volume.h
index 346f228e961..51a7efc1457 100644
--- a/intern/cycles/kernel/geom/geom_volume.h
+++ b/intern/cycles/kernel/geom/geom_volume.h
@@ -47,11 +47,40 @@ ccl_device_inline float3 volume_normalized_position(KernelGlobals *kg,
return P;
}
-ccl_device float volume_attribute_float(KernelGlobals *kg, const ShaderData *sd, const AttributeDescriptor desc, float *dx, float *dy)
+/* Returns normalized P.
+ * If motion blur is enabled, returns normalized and advected P. */
+
+ccl_device_inline float3 volume_get_position(KernelGlobals *kg,
+ const ShaderData *sd)
{
float3 P = volume_normalized_position(kg, sd, sd->P);
+
+ /* Eulerian motion blur. */
+ if(kernel_data.cam.shuttertime != -1.0f) {
+ AttributeDescriptor v_desc = find_attribute(kg, sd, ATTR_STD_VOLUME_VELOCITY);
+
+ if (v_desc.offset != ATTR_STD_NOT_FOUND) {
+ InterpolationType interp = (sd->flag & SD_VOLUME_CUBIC)? INTERPOLATION_CUBIC: INTERPOLATION_NONE;
+
+ /* Find velocity. */
+ float3 velocity = float4_to_float3(kernel_tex_image_interp_3d(kg, v_desc.offset, P.x, P.y, P.z, interp));
+
+ /* Find advected velocity. */
+ P = volume_normalized_position(kg, sd, sd->P + velocity * sd->time);
+ velocity = float4_to_float3(kernel_tex_image_interp_3d(kg, v_desc.offset, P.x, P.y, P.z, interp));
+
+ /* Find advected P. */
+ P = volume_normalized_position(kg, sd, sd->P + velocity * sd->time);
+ }
+ }
+
+ return P;
+}
+
+ccl_device float volume_attribute_float(KernelGlobals *kg, const ShaderData *sd, const AttributeDescriptor desc, float *dx, float *dy)
+{
InterpolationType interp = (sd->flag & SD_VOLUME_CUBIC)? INTERPOLATION_CUBIC: INTERPOLATION_NONE;
- float4 r = kernel_tex_image_interp_3d(kg, desc.offset, P.x, P.y, P.z, interp);
+ float4 r = kernel_tex_image_interp_3d(kg, desc.offset, sd->P_v.x, sd->P_v.y, sd->P_v.z, interp);
if(dx) *dx = 0.0f;
if(dy) *dy = 0.0f;
@@ -61,9 +90,8 @@ ccl_device float volume_attribute_float(KernelGlobals *kg, const ShaderData *sd,
ccl_device float3 volume_attribute_float3(KernelGlobals *kg, const ShaderData *sd, const AttributeDescriptor desc, float3 *dx, float3 *dy)
{
- float3 P = volume_normalized_position(kg, sd, sd->P);
InterpolationType interp = (sd->flag & SD_VOLUME_CUBIC)? INTERPOLATION_CUBIC: INTERPOLATION_NONE;
- float4 r = kernel_tex_image_interp_3d(kg, desc.offset, P.x, P.y, P.z, interp);
+ float4 r = kernel_tex_image_interp_3d(kg, desc.offset, sd->P_v.x, sd->P_v.y, sd->P_v.z, interp);
if(dx) *dx = make_float3(0.0f, 0.0f, 0.0f);
if(dy) *dy = make_float3(0.0f, 0.0f, 0.0f);