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:48 +0400
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2014-03-29 16:03:48 +0400
commit27043b8e40f74c8b0917850d1aefbd6315fa46a5 (patch)
tree26360d0ab051bb94312e40fef974851f3c20f6e0 /intern/cycles/kernel/svm
parent393216a6df934a78f541d98def7a948a89f9b5c8 (diff)
Cycles code internals: add support for mesh voxel grid attributes.
These are internally stored as a 3D image textures, but accessible like e.g. UV coordinates though the attribute node and getattribute(). This is convenient for rendering e.g. smoke objects where data like density is really a property of the mesh, and it avoids having to specify the smoke object in a texture node, instead the material will work with any smoke domain.
Diffstat (limited to 'intern/cycles/kernel/svm')
-rw-r--r--intern/cycles/kernel/svm/svm_attribute.h4
-rw-r--r--intern/cycles/kernel/svm/svm_tex_coord.h45
2 files changed, 14 insertions, 35 deletions
diff --git a/intern/cycles/kernel/svm/svm_attribute.h b/intern/cycles/kernel/svm/svm_attribute.h
index 2592bbe575f..fd0ea7fef31 100644
--- a/intern/cycles/kernel/svm/svm_attribute.h
+++ b/intern/cycles/kernel/svm/svm_attribute.h
@@ -22,12 +22,12 @@ ccl_device void svm_node_attr_init(KernelGlobals *kg, ShaderData *sd,
uint4 node, NodeAttributeType *type,
NodeAttributeType *mesh_type, AttributeElement *elem, int *offset, uint *out_offset)
{
- if(sd->object != OBJECT_NONE && sd->prim != PRIM_NONE) {
+ if(sd->object != OBJECT_NONE) {
/* find attribute by unique id */
uint id = node.y;
uint attr_offset = sd->object*kernel_data.bvh.attributes_map_stride;
#ifdef __HAIR__
- attr_offset = (sd->type & PRIMITIVE_ALL_TRIANGLE)? attr_offset: attr_offset + ATTR_PRIM_CURVE;
+ attr_offset = (sd->type & PRIMITIVE_ALL_CURVE)? attr_offset + ATTR_PRIM_CURVE: attr_offset;
#endif
uint4 attr_map = kernel_tex_fetch(__attributes_map, attr_offset);
diff --git a/intern/cycles/kernel/svm/svm_tex_coord.h b/intern/cycles/kernel/svm/svm_tex_coord.h
index bddeac0b722..a17e4a25efe 100644
--- a/intern/cycles/kernel/svm/svm_tex_coord.h
+++ b/intern/cycles/kernel/svm/svm_tex_coord.h
@@ -70,17 +70,10 @@ ccl_device void svm_node_tex_coord(KernelGlobals *kg, ShaderData *sd, int path_f
case NODE_TEXCO_VOLUME_GENERATED: {
data = sd->P;
- if(sd->object != OBJECT_NONE) {
- AttributeElement attr_elem;
- int attr_offset = find_attribute(kg, sd, ATTR_STD_GENERATED_TRANSFORM, &attr_elem);
-
- object_inverse_position_transform(kg, sd, &data);
-
- if(attr_offset != ATTR_STD_NOT_FOUND) {
- Transform tfm = primitive_attribute_matrix(kg, sd, attr_offset);
- data = transform_point(&tfm, data);
- }
- }
+#ifdef __VOLUME__
+ if(sd->object != OBJECT_NONE)
+ data = volume_normalized_position(kg, sd, data);
+#endif
break;
}
}
@@ -141,17 +134,10 @@ ccl_device void svm_node_tex_coord_bump_dx(KernelGlobals *kg, ShaderData *sd, in
case NODE_TEXCO_VOLUME_GENERATED: {
data = sd->P + sd->dP.dx;
- if(sd->object != OBJECT_NONE) {
- AttributeElement attr_elem;
- int attr_offset = find_attribute(kg, sd, ATTR_STD_GENERATED_TRANSFORM, &attr_elem);
-
- object_inverse_position_transform(kg, sd, &data);
-
- if(attr_offset != ATTR_STD_NOT_FOUND) {
- Transform tfm = primitive_attribute_matrix(kg, sd, attr_offset);
- data = transform_point(&tfm, data);
- }
- }
+#ifdef __VOLUME__
+ if(sd->object != OBJECT_NONE)
+ data = volume_normalized_position(kg, sd, data);
+#endif
break;
}
}
@@ -215,17 +201,10 @@ ccl_device void svm_node_tex_coord_bump_dy(KernelGlobals *kg, ShaderData *sd, in
case NODE_TEXCO_VOLUME_GENERATED: {
data = sd->P + sd->dP.dy;
- if(sd->object != OBJECT_NONE) {
- AttributeElement attr_elem;
- int attr_offset = find_attribute(kg, sd, ATTR_STD_GENERATED_TRANSFORM, &attr_elem);
-
- object_inverse_position_transform(kg, sd, &data);
-
- if(attr_offset != ATTR_STD_NOT_FOUND) {
- Transform tfm = primitive_attribute_matrix(kg, sd, attr_offset);
- data = transform_point(&tfm, data);
- }
- }
+#ifdef __VOLUME__
+ if(sd->object != OBJECT_NONE)
+ data = volume_normalized_position(kg, sd, data);
+#endif
break;
}
}