|
|
|
|
@@ -29,11 +29,6 @@ CCL_NAMESPACE_BEGIN
|
|
|
|
|
enum ObjectTransform {
|
|
|
|
|
OBJECT_TRANSFORM = 0,
|
|
|
|
|
OBJECT_INVERSE_TRANSFORM = 4,
|
|
|
|
|
OBJECT_TRANSFORM_MOTION_PRE = 0,
|
|
|
|
|
OBJECT_TRANSFORM_MOTION_MID = 4,
|
|
|
|
|
OBJECT_TRANSFORM_MOTION_POST = 8,
|
|
|
|
|
OBJECT_PROPERTIES = 12,
|
|
|
|
|
OBJECT_DUPLI = 13
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum ObjectVectorTransform {
|
|
|
|
|
@@ -45,12 +40,17 @@ enum ObjectVectorTransform {
|
|
|
|
|
|
|
|
|
|
ccl_device_inline Transform object_fetch_transform(KernelGlobals *kg, int object, enum ObjectTransform type)
|
|
|
|
|
{
|
|
|
|
|
int offset = object*OBJECT_SIZE + (int)type;
|
|
|
|
|
|
|
|
|
|
Transform tfm;
|
|
|
|
|
tfm.x = kernel_tex_fetch(__objects, offset + 0);
|
|
|
|
|
tfm.y = kernel_tex_fetch(__objects, offset + 1);
|
|
|
|
|
tfm.z = kernel_tex_fetch(__objects, offset + 2);
|
|
|
|
|
if(type == OBJECT_INVERSE_TRANSFORM) {
|
|
|
|
|
tfm.x = kernel_tex_fetch(__objects, object).tfm.mid.x;
|
|
|
|
|
tfm.y = kernel_tex_fetch(__objects, object).tfm.mid.y;
|
|
|
|
|
tfm.z = kernel_tex_fetch(__objects, object).tfm.mid.z;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
tfm.x = kernel_tex_fetch(__objects, object).tfm.pre.x;
|
|
|
|
|
tfm.y = kernel_tex_fetch(__objects, object).tfm.pre.y;
|
|
|
|
|
tfm.z = kernel_tex_fetch(__objects, object).tfm.pre.z;
|
|
|
|
|
}
|
|
|
|
|
tfm.w = make_float4(0.0f, 0.0f, 0.0f, 1.0f);
|
|
|
|
|
|
|
|
|
|
return tfm;
|
|
|
|
|
@@ -91,24 +91,7 @@ ccl_device_inline Transform object_fetch_vector_transform(KernelGlobals *kg, int
|
|
|
|
|
#ifdef __OBJECT_MOTION__
|
|
|
|
|
ccl_device_inline Transform object_fetch_transform_motion(KernelGlobals *kg, int object, float time)
|
|
|
|
|
{
|
|
|
|
|
MotionTransform motion;
|
|
|
|
|
|
|
|
|
|
int offset = object*OBJECT_SIZE + (int)OBJECT_TRANSFORM_MOTION_PRE;
|
|
|
|
|
|
|
|
|
|
motion.pre.x = kernel_tex_fetch(__objects, offset + 0);
|
|
|
|
|
motion.pre.y = kernel_tex_fetch(__objects, offset + 1);
|
|
|
|
|
motion.pre.z = kernel_tex_fetch(__objects, offset + 2);
|
|
|
|
|
motion.pre.w = kernel_tex_fetch(__objects, offset + 3);
|
|
|
|
|
|
|
|
|
|
motion.mid.x = kernel_tex_fetch(__objects, offset + 4);
|
|
|
|
|
motion.mid.y = kernel_tex_fetch(__objects, offset + 5);
|
|
|
|
|
motion.mid.z = kernel_tex_fetch(__objects, offset + 6);
|
|
|
|
|
motion.mid.w = kernel_tex_fetch(__objects, offset + 7);
|
|
|
|
|
|
|
|
|
|
motion.post.x = kernel_tex_fetch(__objects, offset + 8);
|
|
|
|
|
motion.post.y = kernel_tex_fetch(__objects, offset + 9);
|
|
|
|
|
motion.post.z = kernel_tex_fetch(__objects, offset + 10);
|
|
|
|
|
motion.post.w = kernel_tex_fetch(__objects, offset + 11);
|
|
|
|
|
MotionTransform motion = kernel_tex_fetch(__objects, object).tfm;
|
|
|
|
|
|
|
|
|
|
Transform tfm;
|
|
|
|
|
transform_motion_interpolate(&tfm, &motion, time);
|
|
|
|
|
@@ -237,9 +220,7 @@ ccl_device_inline float3 object_location(KernelGlobals *kg, const ShaderData *sd
|
|
|
|
|
|
|
|
|
|
ccl_device_inline float object_surface_area(KernelGlobals *kg, int object)
|
|
|
|
|
{
|
|
|
|
|
int offset = object*OBJECT_SIZE + OBJECT_PROPERTIES;
|
|
|
|
|
float4 f = kernel_tex_fetch(__objects, offset);
|
|
|
|
|
return f.x;
|
|
|
|
|
return kernel_tex_fetch(__objects, object).surface_area;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Pass ID number of object */
|
|
|
|
|
@@ -249,9 +230,7 @@ ccl_device_inline float object_pass_id(KernelGlobals *kg, int object)
|
|
|
|
|
if(object == OBJECT_NONE)
|
|
|
|
|
return 0.0f;
|
|
|
|
|
|
|
|
|
|
int offset = object*OBJECT_SIZE + OBJECT_PROPERTIES;
|
|
|
|
|
float4 f = kernel_tex_fetch(__objects, offset);
|
|
|
|
|
return f.y;
|
|
|
|
|
return kernel_tex_fetch(__objects, object).pass_id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Per lamp random number for shader variation */
|
|
|
|
|
@@ -272,9 +251,7 @@ ccl_device_inline float object_random_number(KernelGlobals *kg, int object)
|
|
|
|
|
if(object == OBJECT_NONE)
|
|
|
|
|
return 0.0f;
|
|
|
|
|
|
|
|
|
|
int offset = object*OBJECT_SIZE + OBJECT_PROPERTIES;
|
|
|
|
|
float4 f = kernel_tex_fetch(__objects, offset);
|
|
|
|
|
return f.z;
|
|
|
|
|
return kernel_tex_fetch(__objects, object).random_number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Particle ID from which this object was generated */
|
|
|
|
|
@@ -284,9 +261,7 @@ ccl_device_inline int object_particle_id(KernelGlobals *kg, int object)
|
|
|
|
|
if(object == OBJECT_NONE)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
int offset = object*OBJECT_SIZE + OBJECT_PROPERTIES;
|
|
|
|
|
float4 f = kernel_tex_fetch(__objects, offset);
|
|
|
|
|
return __float_as_uint(f.w);
|
|
|
|
|
return kernel_tex_fetch(__objects, object).particle_index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Generated texture coordinate on surface from where object was instanced */
|
|
|
|
|
@@ -296,9 +271,10 @@ ccl_device_inline float3 object_dupli_generated(KernelGlobals *kg, int object)
|
|
|
|
|
if(object == OBJECT_NONE)
|
|
|
|
|
return make_float3(0.0f, 0.0f, 0.0f);
|
|
|
|
|
|
|
|
|
|
int offset = object*OBJECT_SIZE + OBJECT_DUPLI;
|
|
|
|
|
float4 f = kernel_tex_fetch(__objects, offset);
|
|
|
|
|
return make_float3(f.x, f.y, f.z);
|
|
|
|
|
const ccl_global KernelObject *kobject = &kernel_tex_fetch(__objects, object);
|
|
|
|
|
return make_float3(kobject->dupli_generated[0],
|
|
|
|
|
kobject->dupli_generated[1],
|
|
|
|
|
kobject->dupli_generated[2]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* UV texture coordinate on surface from where object was instanced */
|
|
|
|
|
@@ -308,27 +284,24 @@ ccl_device_inline float3 object_dupli_uv(KernelGlobals *kg, int object)
|
|
|
|
|
if(object == OBJECT_NONE)
|
|
|
|
|
return make_float3(0.0f, 0.0f, 0.0f);
|
|
|
|
|
|
|
|
|
|
int offset = object*OBJECT_SIZE + OBJECT_DUPLI;
|
|
|
|
|
float4 f = kernel_tex_fetch(__objects, offset + 1);
|
|
|
|
|
return make_float3(f.x, f.y, 0.0f);
|
|
|
|
|
const ccl_global KernelObject *kobject = &kernel_tex_fetch(__objects, object);
|
|
|
|
|
return make_float3(kobject->dupli_uv[0],
|
|
|
|
|
kobject->dupli_uv[1],
|
|
|
|
|
0.0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Information about mesh for motion blurred triangles and curves */
|
|
|
|
|
|
|
|
|
|
ccl_device_inline void object_motion_info(KernelGlobals *kg, int object, int *numsteps, int *numverts, int *numkeys)
|
|
|
|
|
{
|
|
|
|
|
int offset = object*OBJECT_SIZE + OBJECT_DUPLI;
|
|
|
|
|
|
|
|
|
|
if(numkeys) {
|
|
|
|
|
float4 f = kernel_tex_fetch(__objects, offset);
|
|
|
|
|
*numkeys = __float_as_int(f.w);
|
|
|
|
|
*numkeys = kernel_tex_fetch(__objects, object).numkeys;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float4 f = kernel_tex_fetch(__objects, offset + 1);
|
|
|
|
|
if(numsteps)
|
|
|
|
|
*numsteps = __float_as_int(f.z);
|
|
|
|
|
*numsteps = kernel_tex_fetch(__objects, object).numsteps;
|
|
|
|
|
if(numverts)
|
|
|
|
|
*numverts = __float_as_int(f.w);
|
|
|
|
|
*numverts = kernel_tex_fetch(__objects, object).numverts;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Offset to an objects patch map */
|
|
|
|
|
@@ -338,9 +311,7 @@ ccl_device_inline uint object_patch_map_offset(KernelGlobals *kg, int object)
|
|
|
|
|
if(object == OBJECT_NONE)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
int offset = object*OBJECT_SIZE + 15;
|
|
|
|
|
float4 f = kernel_tex_fetch(__objects, offset);
|
|
|
|
|
return __float_as_uint(f.x);
|
|
|
|
|
return kernel_tex_fetch(__objects, object).patch_map_offset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Pass ID for shader */
|
|
|
|
|
|