Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/geom/geom_attribute.h
| Show All 21 Lines | |||||
| * | * | ||||
| * We support an arbitrary number of attributes on various mesh elements. | * We support an arbitrary number of attributes on various mesh elements. | ||||
| * On vertices, triangles, curve keys, curves, meshes and volume grids. | * On vertices, triangles, curve keys, curves, meshes and volume grids. | ||||
| * Most of the code for attribute reading is in the primitive files. | * Most of the code for attribute reading is in the primitive files. | ||||
| * | * | ||||
| * Lookup of attributes is different between OSL and SVM, as OSL is ustring | * Lookup of attributes is different between OSL and SVM, as OSL is ustring | ||||
| * based while for SVM we use integer ids. */ | * based while for SVM we use integer ids. */ | ||||
| ccl_device_inline uint subd_triangle_patch(ccl_global const KernelGlobals *kg, | ccl_device_inline uint subd_triangle_patch(KernelGlobals kg, ccl_private const ShaderData *sd); | ||||
| ccl_private const ShaderData *sd); | |||||
| ccl_device_inline uint attribute_primitive_type(ccl_global const KernelGlobals *kg, | ccl_device_inline uint attribute_primitive_type(KernelGlobals kg, ccl_private const ShaderData *sd) | ||||
| ccl_private const ShaderData *sd) | |||||
| { | { | ||||
| if ((sd->type & PRIMITIVE_ALL_TRIANGLE) && subd_triangle_patch(kg, sd) != ~0) { | if ((sd->type & PRIMITIVE_ALL_TRIANGLE) && subd_triangle_patch(kg, sd) != ~0) { | ||||
| return ATTR_PRIM_SUBD; | return ATTR_PRIM_SUBD; | ||||
| } | } | ||||
| else { | else { | ||||
| return ATTR_PRIM_GEOMETRY; | return ATTR_PRIM_GEOMETRY; | ||||
| } | } | ||||
| } | } | ||||
| ccl_device_inline AttributeDescriptor attribute_not_found() | ccl_device_inline AttributeDescriptor attribute_not_found() | ||||
| { | { | ||||
| const AttributeDescriptor desc = { | const AttributeDescriptor desc = { | ||||
| ATTR_ELEMENT_NONE, (NodeAttributeType)0, 0, ATTR_STD_NOT_FOUND}; | ATTR_ELEMENT_NONE, (NodeAttributeType)0, 0, ATTR_STD_NOT_FOUND}; | ||||
| return desc; | return desc; | ||||
| } | } | ||||
| /* Find attribute based on ID */ | /* Find attribute based on ID */ | ||||
| ccl_device_inline uint object_attribute_map_offset(ccl_global const KernelGlobals *kg, int object) | ccl_device_inline uint object_attribute_map_offset(KernelGlobals kg, int object) | ||||
| { | { | ||||
| return kernel_tex_fetch(__objects, object).attribute_map_offset; | return kernel_tex_fetch(__objects, object).attribute_map_offset; | ||||
| } | } | ||||
| ccl_device_inline AttributeDescriptor find_attribute(ccl_global const KernelGlobals *kg, | ccl_device_inline AttributeDescriptor find_attribute(KernelGlobals kg, | ||||
| ccl_private const ShaderData *sd, | ccl_private const ShaderData *sd, | ||||
| uint id) | uint id) | ||||
| { | { | ||||
| if (sd->object == OBJECT_NONE) { | if (sd->object == OBJECT_NONE) { | ||||
| return attribute_not_found(); | return attribute_not_found(); | ||||
| } | } | ||||
| /* for SVM, find attribute by unique id */ | /* for SVM, find attribute by unique id */ | ||||
| Show All 30 Lines | ccl_device_inline AttributeDescriptor find_attribute(KernelGlobals kg, | ||||
| desc.type = (NodeAttributeType)(attr_map.w & 0xff); | desc.type = (NodeAttributeType)(attr_map.w & 0xff); | ||||
| desc.flags = (AttributeFlag)(attr_map.w >> 8); | desc.flags = (AttributeFlag)(attr_map.w >> 8); | ||||
| return desc; | return desc; | ||||
| } | } | ||||
| /* Transform matrix attribute on meshes */ | /* Transform matrix attribute on meshes */ | ||||
| ccl_device Transform primitive_attribute_matrix(ccl_global const KernelGlobals *kg, | ccl_device Transform primitive_attribute_matrix(KernelGlobals kg, | ||||
| ccl_private const ShaderData *sd, | ccl_private const ShaderData *sd, | ||||
| const AttributeDescriptor desc) | const AttributeDescriptor desc) | ||||
| { | { | ||||
| Transform tfm; | Transform tfm; | ||||
| tfm.x = kernel_tex_fetch(__attributes_float3, desc.offset + 0); | tfm.x = kernel_tex_fetch(__attributes_float3, desc.offset + 0); | ||||
| tfm.y = kernel_tex_fetch(__attributes_float3, desc.offset + 1); | tfm.y = kernel_tex_fetch(__attributes_float3, desc.offset + 1); | ||||
| tfm.z = kernel_tex_fetch(__attributes_float3, desc.offset + 2); | tfm.z = kernel_tex_fetch(__attributes_float3, desc.offset + 2); | ||||
| return tfm; | return tfm; | ||||
| } | } | ||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||