Added a bunch of additional particle state attributes to the Cycles particle info node:
* Location: Basically the same as the location from Object Info node for object instances on particles, but in principle there could be additional offsets for dupli objects, so included for completeness. * Size: Single float scale of the particle. Also directly translates to object scale for current dupli objects, but handy to have as a single float to start with instead of a scale vector (currently not even exposed in Object Info). * Rotation: This is a quaternion, which are not yet supported by Cycles nodes. The float4 is copied to internal Cycles data and stored in the particles texture data, but the node doesn't have a socket for it yet and the data is not yet written to the stack. Code is just commented out so could be enabled quickly if/when rotation support is added to cycles. * Velocity: Linear velocity vector of particles. * Angular Velocity: Angular velocity around principle axes. The texture data is currently packed tightly into the particles texture, which saves a few bytes, but requires an additional texture lookup for some vector attributes which spread over two float4s. Could also add another float4 to particle size to avoid this.
This commit is contained in:
@@ -172,24 +172,61 @@ __device int shader_pass_id(KernelGlobals *kg, ShaderData *sd)
|
||||
__device_inline float particle_index(KernelGlobals *kg, int particle)
|
||||
{
|
||||
int offset = particle*PARTICLE_SIZE;
|
||||
float4 f = kernel_tex_fetch(__particles, offset);
|
||||
float4 f = kernel_tex_fetch(__particles, offset + 0);
|
||||
return f.x;
|
||||
}
|
||||
|
||||
__device float particle_age(KernelGlobals *kg, int particle)
|
||||
{
|
||||
int offset = particle*PARTICLE_SIZE;
|
||||
float4 f = kernel_tex_fetch(__particles, offset);
|
||||
float4 f = kernel_tex_fetch(__particles, offset + 0);
|
||||
return f.y;
|
||||
}
|
||||
|
||||
__device float particle_lifetime(KernelGlobals *kg, int particle)
|
||||
{
|
||||
int offset = particle*PARTICLE_SIZE;
|
||||
float4 f = kernel_tex_fetch(__particles, offset);
|
||||
float4 f = kernel_tex_fetch(__particles, offset + 0);
|
||||
return f.z;
|
||||
}
|
||||
|
||||
__device float particle_size(KernelGlobals *kg, int particle)
|
||||
{
|
||||
int offset = particle*PARTICLE_SIZE;
|
||||
float4 f = kernel_tex_fetch(__particles, offset + 0);
|
||||
return f.w;
|
||||
}
|
||||
|
||||
__device float4 particle_rotation(KernelGlobals *kg, int particle)
|
||||
{
|
||||
int offset = particle*PARTICLE_SIZE;
|
||||
float4 f = kernel_tex_fetch(__particles, offset + 1);
|
||||
return f;
|
||||
}
|
||||
|
||||
__device float3 particle_location(KernelGlobals *kg, int particle)
|
||||
{
|
||||
int offset = particle*PARTICLE_SIZE;
|
||||
float4 f = kernel_tex_fetch(__particles, offset + 2);
|
||||
return make_float3(f.x, f.y, f.z);
|
||||
}
|
||||
|
||||
__device float3 particle_velocity(KernelGlobals *kg, int particle)
|
||||
{
|
||||
int offset = particle*PARTICLE_SIZE;
|
||||
float4 f2 = kernel_tex_fetch(__particles, offset + 2);
|
||||
float4 f3 = kernel_tex_fetch(__particles, offset + 3);
|
||||
return make_float3(f2.w, f3.x, f3.y);
|
||||
}
|
||||
|
||||
__device float3 particle_angular_velocity(KernelGlobals *kg, int particle)
|
||||
{
|
||||
int offset = particle*PARTICLE_SIZE;
|
||||
float4 f3 = kernel_tex_fetch(__particles, offset + 3);
|
||||
float4 f4 = kernel_tex_fetch(__particles, offset + 4);
|
||||
return make_float3(f3.z, f3.w, f4.x);
|
||||
}
|
||||
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
|
||||
Reference in New Issue
Block a user