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/geom/geom_primitive.h
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/geom/geom_primitive.h')
-rw-r--r--intern/cycles/kernel/geom/geom_primitive.h36
1 files changed, 28 insertions, 8 deletions
diff --git a/intern/cycles/kernel/geom/geom_primitive.h b/intern/cycles/kernel/geom/geom_primitive.h
index d90cc108492..f821e696a07 100644
--- a/intern/cycles/kernel/geom/geom_primitive.h
+++ b/intern/cycles/kernel/geom/geom_primitive.h
@@ -25,26 +25,46 @@ CCL_NAMESPACE_BEGIN
ccl_device float primitive_attribute_float(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float *dx, float *dy)
{
-#ifdef __HAIR__
- if(sd->type & PRIMITIVE_ALL_TRIANGLE)
-#endif
+ if(sd->type & PRIMITIVE_ALL_TRIANGLE) {
return triangle_attribute_float(kg, sd, elem, offset, dx, dy);
+ }
#ifdef __HAIR__
- else
+ else if(sd->type & PRIMITIVE_ALL_CURVE) {
return curve_attribute_float(kg, sd, elem, offset, dx, dy);
+ }
#endif
+#ifdef __VOLUME__
+ else if(sd->object != OBJECT_NONE && elem == ATTR_ELEMENT_VOXEL) {
+ return volume_attribute_float(kg, sd, elem, offset, dx, dy);
+ }
+#endif
+ else {
+ if(dx) *dx = 0.0f;
+ if(dy) *dy = 0.0f;
+ return 0.0f;
+ }
}
ccl_device float3 primitive_attribute_float3(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float3 *dx, float3 *dy)
{
-#ifdef __HAIR__
- if(sd->type & PRIMITIVE_ALL_TRIANGLE)
-#endif
+ if(sd->type & PRIMITIVE_ALL_TRIANGLE) {
return triangle_attribute_float3(kg, sd, elem, offset, dx, dy);
+ }
#ifdef __HAIR__
- else
+ else if(sd->type & PRIMITIVE_ALL_CURVE) {
return curve_attribute_float3(kg, sd, elem, offset, dx, dy);
+ }
+#endif
+#ifdef __VOLUME__
+ else if(sd->object != OBJECT_NONE && elem == ATTR_ELEMENT_VOXEL) {
+ return volume_attribute_float3(kg, sd, elem, offset, dx, dy);
+ }
#endif
+ else {
+ if(dx) *dx = make_float3(0.0f, 0.0f, 0.0f);
+ if(dy) *dy = make_float3(0.0f, 0.0f, 0.0f);
+ return make_float3(0.0f, 0.0f, 0.0f);
+ }
}
/* Default UV coordinate */