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:
authorLukas Toenne <lukas.toenne@googlemail.com>2012-06-08 20:17:57 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2012-06-08 20:17:57 +0400
commit5e1bbde01d0a77c7b032197cff860305462a9cb2 (patch)
treef751a45ac32c7d210b5e54b5d0a9efab61e16d24 /intern/cycles/kernel/kernel_object.h
parent82d3d9f2ba47bbf2f868b5a970d1fe149eba13e2 (diff)
Particle Info node for Cycles. This can be used to access particle information in material shaders for dupli objects. For now only the particle Age and individual Lifetime (in frames) are supported, more attributes can be added when needed.
The particle data is stored in a separate texture if any of the dupli objects uses particle info nodes in shaders. To map dupli objects onto particles the store an additional particle_index value, which is different from the simple dupli object index (only visible particles, also works for particle dupli groups mode). Some simple use cases on the code.blender.org blog: http://code.blender.org/index.php/2012/05/particle-info-node/
Diffstat (limited to 'intern/cycles/kernel/kernel_object.h')
-rw-r--r--intern/cycles/kernel/kernel_object.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/intern/cycles/kernel/kernel_object.h b/intern/cycles/kernel/kernel_object.h
index 05c45c490d8..18e0b1e8a87 100644
--- a/intern/cycles/kernel/kernel_object.h
+++ b/intern/cycles/kernel/kernel_object.h
@@ -154,10 +154,35 @@ __device_inline float object_random_number(KernelGlobals *kg, int object)
return f.z;
}
+__device_inline uint object_particle_id(KernelGlobals *kg, int object)
+{
+ if(object == ~0)
+ return 0.0f;
+
+ int offset = object*OBJECT_SIZE + OBJECT_PROPERTIES;
+ float4 f = kernel_tex_fetch(__objects, offset);
+ return __float_as_int(f.w);
+}
+
__device int shader_pass_id(KernelGlobals *kg, ShaderData *sd)
{
return kernel_tex_fetch(__shader_flag, (sd->shader & SHADER_MASK)*2 + 1);
}
+__device float particle_age(KernelGlobals *kg, int particle)
+{
+ int offset = particle*PARTICLE_SIZE;
+ float4 f = kernel_tex_fetch(__particles, offset);
+ return f.x;
+}
+
+__device float particle_lifetime(KernelGlobals *kg, int particle)
+{
+ int offset = particle*PARTICLE_SIZE;
+ float4 f = kernel_tex_fetch(__particles, offset);
+ return f.y;
+}
+
+
CCL_NAMESPACE_END