Cycles: add "From Dupli" option for texture coordinate node. This gets the

Generated and UV coordinates from the duplicator of instance instead of the
object itself.

This was used in e.g. Big Buck Bunny for texturing instanced feathers with
a UV map on the bird. Many files changed, mainly to do some refactoring to
get rid of G.rendering global in duplilist code.
This commit is contained in:
Brecht Van Lommel
2012-10-04 21:40:39 +00:00
parent 984e9f9cc8
commit fedc8e1722
32 changed files with 222 additions and 80 deletions

View File

@@ -23,7 +23,8 @@ enum ObjectTransform {
OBJECT_INVERSE_TRANSFORM = 3,
OBJECT_PROPERTIES = 6,
OBJECT_TRANSFORM_MOTION_PRE = 8,
OBJECT_TRANSFORM_MOTION_POST = 12
OBJECT_TRANSFORM_MOTION_POST = 12,
OBJECT_DUPLI = 16
};
__device_inline Transform object_fetch_transform(KernelGlobals *kg, int object, float time, enum ObjectTransform type)
@@ -164,6 +165,27 @@ __device_inline uint object_particle_id(KernelGlobals *kg, int object)
return __float_as_int(f.w);
}
__device_inline float3 object_dupli_generated(KernelGlobals *kg, int object)
{
if(object == ~0)
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);
}
__device_inline float3 object_dupli_uv(KernelGlobals *kg, int object)
{
if(object == ~0)
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);
}
__device int shader_pass_id(KernelGlobals *kg, ShaderData *sd)
{
return kernel_tex_fetch(__shader_flag, (sd->shader & SHADER_MASK)*2 + 1);