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-07-26 15:40:58 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2012-07-26 15:40:58 +0400
commitfec872ef9c0bb6904cbe9a7b59b3f51ae7bb0702 (patch)
treeaeb75f40ec873b33dd1e76e55ab0f05eac1768a9 /intern/cycles/kernel/kernel_object.h
parent53a861b6f9ece221089b9364fa5a9e87175b580c (diff)
Added a particle index output to the Particle Info Cycles node. This is required to get consistent ID numbers for particles. The Object ID is not usable since it's a user defined value of the instanced object, which does not vary per instance. Also the random value from the object info node is not consistent over time, since it only depends on the index in the dupli list (so each emitted or dying particle shifts the value).
The particle index is always the same for a specific particle. Randomized values can be generated from this with the use of a noise texture.
Diffstat (limited to 'intern/cycles/kernel/kernel_object.h')
-rw-r--r--intern/cycles/kernel/kernel_object.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/intern/cycles/kernel/kernel_object.h b/intern/cycles/kernel/kernel_object.h
index 18e0b1e8a87..4ff315ca265 100644
--- a/intern/cycles/kernel/kernel_object.h
+++ b/intern/cycles/kernel/kernel_object.h
@@ -169,20 +169,27 @@ __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)
+__device_inline float particle_index(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)
+__device float particle_age(KernelGlobals *kg, int particle)
{
int offset = particle*PARTICLE_SIZE;
float4 f = kernel_tex_fetch(__particles, offset);
return f.y;
}
+__device float particle_lifetime(KernelGlobals *kg, int particle)
+{
+ int offset = particle*PARTICLE_SIZE;
+ float4 f = kernel_tex_fetch(__particles, offset);
+ return f.z;
+}
+
CCL_NAMESPACE_END