diff options
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/kernel/geom/geom_primitive.h | 2 | ||||
-rw-r--r-- | intern/cycles/kernel/geom/geom_volume.h | 24 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_shader.h | 1 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_types.h | 7 |
4 files changed, 23 insertions, 11 deletions
diff --git a/intern/cycles/kernel/geom/geom_primitive.h b/intern/cycles/kernel/geom/geom_primitive.h index 2c31e5cee03..aeb044c9ad3 100644 --- a/intern/cycles/kernel/geom/geom_primitive.h +++ b/intern/cycles/kernel/geom/geom_primitive.h @@ -138,7 +138,7 @@ ccl_device_inline float4 primitive_surface_attribute_float4(KernelGlobals *kg, ccl_device_inline bool primitive_is_volume_attribute(const ShaderData *sd, const AttributeDescriptor desc) { - return (sd->object != OBJECT_NONE && desc.element == ATTR_ELEMENT_VOXEL); + return sd->type == PRIMITIVE_VOLUME; } ccl_device_inline float primitive_volume_attribute_float(KernelGlobals *kg, diff --git a/intern/cycles/kernel/geom/geom_volume.h b/intern/cycles/kernel/geom/geom_volume.h index 13b027a5f6c..809b76245ba 100644 --- a/intern/cycles/kernel/geom/geom_volume.h +++ b/intern/cycles/kernel/geom/geom_volume.h @@ -72,14 +72,22 @@ ccl_device float4 volume_attribute_float4(KernelGlobals *kg, const ShaderData *sd, const AttributeDescriptor desc) { - /* todo: optimize this so we don't have to transform both here and in - * kernel_tex_image_interp_3d when possible. Also could optimize for the - * common case where transform is translation/scale only. */ - float3 P = sd->P; - object_inverse_position_transform(kg, sd, &P); - InterpolationType interp = (sd->flag & SD_VOLUME_CUBIC) ? INTERPOLATION_CUBIC : - INTERPOLATION_NONE; - return kernel_tex_image_interp_3d(kg, desc.offset, P, interp); + if (desc.element & (ATTR_ELEMENT_OBJECT | ATTR_ELEMENT_MESH)) { + return kernel_tex_fetch(__attributes_float3, desc.offset); + } + else if (desc.element == ATTR_ELEMENT_VOXEL) { + /* todo: optimize this so we don't have to transform both here and in + * kernel_tex_image_interp_3d when possible. Also could optimize for the + * common case where transform is translation/scale only. */ + float3 P = sd->P; + object_inverse_position_transform(kg, sd, &P); + InterpolationType interp = (sd->flag & SD_VOLUME_CUBIC) ? INTERPOLATION_CUBIC : + INTERPOLATION_NONE; + return kernel_tex_image_interp_3d(kg, desc.offset, P, interp); + } + else { + return make_float4(0.0f, 0.0f, 0.0f, 0.0f); + } } #endif diff --git a/intern/cycles/kernel/kernel_shader.h b/intern/cycles/kernel/kernel_shader.h index 92b4a9cbf9e..7f02e6fc7b3 100644 --- a/intern/cycles/kernel/kernel_shader.h +++ b/intern/cycles/kernel/kernel_shader.h @@ -1268,6 +1268,7 @@ ccl_device_inline void shader_eval_volume(KernelGlobals *kg, sd->num_closure_left = max_closures; sd->flag = 0; sd->object_flag = 0; + sd->type = PRIMITIVE_VOLUME; for (int i = 0; stack[i].shader != SHADER_NONE; i++) { /* setup shaderdata from stack. it's mostly setup already in diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index 85d75b36e5f..48aa2ca76e6 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -694,17 +694,20 @@ typedef enum PrimitiveType { */ PRIMITIVE_LAMP = (1 << 6), + PRIMITIVE_VOLUME = (1 << 7), + PRIMITIVE_ALL_TRIANGLE = (PRIMITIVE_TRIANGLE | PRIMITIVE_MOTION_TRIANGLE), PRIMITIVE_ALL_CURVE = (PRIMITIVE_CURVE_THICK | PRIMITIVE_MOTION_CURVE_THICK | PRIMITIVE_CURVE_RIBBON | PRIMITIVE_MOTION_CURVE_RIBBON), + PRIMITIVE_ALL_VOLUME = (PRIMITIVE_VOLUME), PRIMITIVE_ALL_MOTION = (PRIMITIVE_MOTION_TRIANGLE | PRIMITIVE_MOTION_CURVE_THICK | PRIMITIVE_MOTION_CURVE_RIBBON), - PRIMITIVE_ALL = (PRIMITIVE_ALL_TRIANGLE | PRIMITIVE_ALL_CURVE), + PRIMITIVE_ALL = (PRIMITIVE_ALL_TRIANGLE | PRIMITIVE_ALL_CURVE | PRIMITIVE_ALL_VOLUME), /* Total number of different traceable primitives. * NOTE: This is an actual value, not a bitflag. */ - PRIMITIVE_NUM_TOTAL = 6, + PRIMITIVE_NUM_TOTAL = 7, } PrimitiveType; #define PRIMITIVE_PACK_SEGMENT(type, segment) ((segment << PRIMITIVE_NUM_TOTAL) | (type)) |