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:
authorKévin Dietrich <kevin.dietrich@mailoo.org>2021-06-28 19:49:55 +0300
committerKévin Dietrich <kevin.dietrich@mailoo.org>2021-06-28 20:09:15 +0300
commita5ed075110031792212a7f6b8a171242a3f428e8 (patch)
tree68b4f93c2edcbba8e449904505a33954aa125e4c /intern/cycles/kernel/geom
parentafb17552e19c56daab6928ed1e2514b962770e19 (diff)
Fix T87194: custom attributes not accessible with Cycles Volume
Custom properties defined on objects are not accessible from the attribute node when rendering a volume in Cycles. This is because this case is not handled. To handle it, added a primitive type for volumes in the kernel, which is then used in the initialization of ShaderData and to check whether an attribute lookup is for a volume. `volume_attribute_float4` is also now checking the attribute element type to dispatch to the right lookup function. Reviewed By: #cycles, brecht Maniphest Tasks: T87194 Differential Revision: https://developer.blender.org/D11728
Diffstat (limited to 'intern/cycles/kernel/geom')
-rw-r--r--intern/cycles/kernel/geom/geom_primitive.h2
-rw-r--r--intern/cycles/kernel/geom/geom_volume.h24
2 files changed, 17 insertions, 9 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