Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/geom/geom_primitive.h
| Show All 25 Lines | |||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| /* Surface Attributes | /* Surface Attributes | ||||
| * | * | ||||
| * Read geometry attributes for surface shading. This is distinct from volume | * Read geometry attributes for surface shading. This is distinct from volume | ||||
| * attributes for performance, mainly for GPU performance to avoid bringing in | * attributes for performance, mainly for GPU performance to avoid bringing in | ||||
| * heavy volume interpolation code. */ | * heavy volume interpolation code. */ | ||||
| ccl_device_inline float primitive_surface_attribute_float(ccl_global const KernelGlobals *kg, | ccl_device_inline float primitive_surface_attribute_float(KernelGlobals kg, | ||||
| ccl_private const ShaderData *sd, | ccl_private const ShaderData *sd, | ||||
| const AttributeDescriptor desc, | const AttributeDescriptor desc, | ||||
| ccl_private float *dx, | ccl_private float *dx, | ||||
| ccl_private float *dy) | ccl_private float *dy) | ||||
| { | { | ||||
| if (sd->type & PRIMITIVE_ALL_TRIANGLE) { | if (sd->type & PRIMITIVE_ALL_TRIANGLE) { | ||||
| if (subd_triangle_patch(kg, sd) == ~0) | if (subd_triangle_patch(kg, sd) == ~0) | ||||
| return triangle_attribute_float(kg, sd, desc, dx, dy); | return triangle_attribute_float(kg, sd, desc, dx, dy); | ||||
| Show All 9 Lines | else { | ||||
| if (dx) | if (dx) | ||||
| *dx = 0.0f; | *dx = 0.0f; | ||||
| if (dy) | if (dy) | ||||
| *dy = 0.0f; | *dy = 0.0f; | ||||
| return 0.0f; | return 0.0f; | ||||
| } | } | ||||
| } | } | ||||
| ccl_device_inline float2 primitive_surface_attribute_float2(ccl_global const KernelGlobals *kg, | ccl_device_inline float2 primitive_surface_attribute_float2(KernelGlobals kg, | ||||
| ccl_private const ShaderData *sd, | ccl_private const ShaderData *sd, | ||||
| const AttributeDescriptor desc, | const AttributeDescriptor desc, | ||||
| ccl_private float2 *dx, | ccl_private float2 *dx, | ||||
| ccl_private float2 *dy) | ccl_private float2 *dy) | ||||
| { | { | ||||
| if (sd->type & PRIMITIVE_ALL_TRIANGLE) { | if (sd->type & PRIMITIVE_ALL_TRIANGLE) { | ||||
| if (subd_triangle_patch(kg, sd) == ~0) | if (subd_triangle_patch(kg, sd) == ~0) | ||||
| return triangle_attribute_float2(kg, sd, desc, dx, dy); | return triangle_attribute_float2(kg, sd, desc, dx, dy); | ||||
| Show All 9 Lines | else { | ||||
| if (dx) | if (dx) | ||||
| *dx = make_float2(0.0f, 0.0f); | *dx = make_float2(0.0f, 0.0f); | ||||
| if (dy) | if (dy) | ||||
| *dy = make_float2(0.0f, 0.0f); | *dy = make_float2(0.0f, 0.0f); | ||||
| return make_float2(0.0f, 0.0f); | return make_float2(0.0f, 0.0f); | ||||
| } | } | ||||
| } | } | ||||
| ccl_device_inline float3 primitive_surface_attribute_float3(ccl_global const KernelGlobals *kg, | ccl_device_inline float3 primitive_surface_attribute_float3(KernelGlobals kg, | ||||
| ccl_private const ShaderData *sd, | ccl_private const ShaderData *sd, | ||||
| const AttributeDescriptor desc, | const AttributeDescriptor desc, | ||||
| ccl_private float3 *dx, | ccl_private float3 *dx, | ||||
| ccl_private float3 *dy) | ccl_private float3 *dy) | ||||
| { | { | ||||
| if (sd->type & PRIMITIVE_ALL_TRIANGLE) { | if (sd->type & PRIMITIVE_ALL_TRIANGLE) { | ||||
| if (subd_triangle_patch(kg, sd) == ~0) | if (subd_triangle_patch(kg, sd) == ~0) | ||||
| return triangle_attribute_float3(kg, sd, desc, dx, dy); | return triangle_attribute_float3(kg, sd, desc, dx, dy); | ||||
| Show All 9 Lines | else { | ||||
| if (dx) | if (dx) | ||||
| *dx = make_float3(0.0f, 0.0f, 0.0f); | *dx = make_float3(0.0f, 0.0f, 0.0f); | ||||
| if (dy) | if (dy) | ||||
| *dy = make_float3(0.0f, 0.0f, 0.0f); | *dy = make_float3(0.0f, 0.0f, 0.0f); | ||||
| return make_float3(0.0f, 0.0f, 0.0f); | return make_float3(0.0f, 0.0f, 0.0f); | ||||
| } | } | ||||
| } | } | ||||
| ccl_device_forceinline float4 | ccl_device_forceinline float4 primitive_surface_attribute_float4(KernelGlobals kg, | ||||
| primitive_surface_attribute_float4(ccl_global const KernelGlobals *kg, | |||||
| ccl_private const ShaderData *sd, | ccl_private const ShaderData *sd, | ||||
| const AttributeDescriptor desc, | const AttributeDescriptor desc, | ||||
| ccl_private float4 *dx, | ccl_private float4 *dx, | ||||
| ccl_private float4 *dy) | ccl_private float4 *dy) | ||||
| { | { | ||||
| if (sd->type & PRIMITIVE_ALL_TRIANGLE) { | if (sd->type & PRIMITIVE_ALL_TRIANGLE) { | ||||
| if (subd_triangle_patch(kg, sd) == ~0) | if (subd_triangle_patch(kg, sd) == ~0) | ||||
| return triangle_attribute_float4(kg, sd, desc, dx, dy); | return triangle_attribute_float4(kg, sd, desc, dx, dy); | ||||
| else | else | ||||
| return subd_triangle_attribute_float4(kg, sd, desc, dx, dy); | return subd_triangle_attribute_float4(kg, sd, desc, dx, dy); | ||||
| } | } | ||||
| #ifdef __HAIR__ | #ifdef __HAIR__ | ||||
| Show All 18 Lines | |||||
| * heavy volume interpolation code. */ | * heavy volume interpolation code. */ | ||||
| ccl_device_inline bool primitive_is_volume_attribute(ccl_private const ShaderData *sd, | ccl_device_inline bool primitive_is_volume_attribute(ccl_private const ShaderData *sd, | ||||
| const AttributeDescriptor desc) | const AttributeDescriptor desc) | ||||
| { | { | ||||
| return sd->type == PRIMITIVE_VOLUME; | return sd->type == PRIMITIVE_VOLUME; | ||||
| } | } | ||||
| ccl_device_inline float primitive_volume_attribute_float(ccl_global const KernelGlobals *kg, | ccl_device_inline float primitive_volume_attribute_float(KernelGlobals kg, | ||||
| ccl_private const ShaderData *sd, | ccl_private const ShaderData *sd, | ||||
| const AttributeDescriptor desc) | const AttributeDescriptor desc) | ||||
| { | { | ||||
| if (primitive_is_volume_attribute(sd, desc)) { | if (primitive_is_volume_attribute(sd, desc)) { | ||||
| return volume_attribute_value_to_float(volume_attribute_float4(kg, sd, desc)); | return volume_attribute_value_to_float(volume_attribute_float4(kg, sd, desc)); | ||||
| } | } | ||||
| else { | else { | ||||
| return 0.0f; | return 0.0f; | ||||
| } | } | ||||
| } | } | ||||
| ccl_device_inline float3 primitive_volume_attribute_float3(ccl_global const KernelGlobals *kg, | ccl_device_inline float3 primitive_volume_attribute_float3(KernelGlobals kg, | ||||
| ccl_private const ShaderData *sd, | ccl_private const ShaderData *sd, | ||||
| const AttributeDescriptor desc) | const AttributeDescriptor desc) | ||||
| { | { | ||||
| if (primitive_is_volume_attribute(sd, desc)) { | if (primitive_is_volume_attribute(sd, desc)) { | ||||
| return volume_attribute_value_to_float3(volume_attribute_float4(kg, sd, desc)); | return volume_attribute_value_to_float3(volume_attribute_float4(kg, sd, desc)); | ||||
| } | } | ||||
| else { | else { | ||||
| return make_float3(0.0f, 0.0f, 0.0f); | return make_float3(0.0f, 0.0f, 0.0f); | ||||
| } | } | ||||
| } | } | ||||
| ccl_device_inline float4 primitive_volume_attribute_float4(ccl_global const KernelGlobals *kg, | ccl_device_inline float4 primitive_volume_attribute_float4(KernelGlobals kg, | ||||
| ccl_private const ShaderData *sd, | ccl_private const ShaderData *sd, | ||||
| const AttributeDescriptor desc) | const AttributeDescriptor desc) | ||||
| { | { | ||||
| if (primitive_is_volume_attribute(sd, desc)) { | if (primitive_is_volume_attribute(sd, desc)) { | ||||
| return volume_attribute_float4(kg, sd, desc); | return volume_attribute_float4(kg, sd, desc); | ||||
| } | } | ||||
| else { | else { | ||||
| return make_float4(0.0f, 0.0f, 0.0f, 0.0f); | return make_float4(0.0f, 0.0f, 0.0f, 0.0f); | ||||
| } | } | ||||
| } | } | ||||
| #endif | #endif | ||||
| /* Default UV coordinate */ | /* Default UV coordinate */ | ||||
| ccl_device_inline float3 primitive_uv(ccl_global const KernelGlobals *kg, | ccl_device_inline float3 primitive_uv(KernelGlobals kg, ccl_private const ShaderData *sd) | ||||
| ccl_private const ShaderData *sd) | |||||
| { | { | ||||
| const AttributeDescriptor desc = find_attribute(kg, sd, ATTR_STD_UV); | const AttributeDescriptor desc = find_attribute(kg, sd, ATTR_STD_UV); | ||||
| if (desc.offset == ATTR_STD_NOT_FOUND) | if (desc.offset == ATTR_STD_NOT_FOUND) | ||||
| return make_float3(0.0f, 0.0f, 0.0f); | return make_float3(0.0f, 0.0f, 0.0f); | ||||
| float2 uv = primitive_surface_attribute_float2(kg, sd, desc, NULL, NULL); | float2 uv = primitive_surface_attribute_float2(kg, sd, desc, NULL, NULL); | ||||
| return make_float3(uv.x, uv.y, 1.0f); | return make_float3(uv.x, uv.y, 1.0f); | ||||
| } | } | ||||
| /* Ptex coordinates */ | /* Ptex coordinates */ | ||||
| ccl_device bool primitive_ptex(ccl_global const KernelGlobals *kg, | ccl_device bool primitive_ptex(KernelGlobals kg, | ||||
| ccl_private ShaderData *sd, | ccl_private ShaderData *sd, | ||||
| ccl_private float2 *uv, | ccl_private float2 *uv, | ||||
| ccl_private int *face_id) | ccl_private int *face_id) | ||||
| { | { | ||||
| /* storing ptex data as attributes is not memory efficient but simple for tests */ | /* storing ptex data as attributes is not memory efficient but simple for tests */ | ||||
| const AttributeDescriptor desc_face_id = find_attribute(kg, sd, ATTR_STD_PTEX_FACE_ID); | const AttributeDescriptor desc_face_id = find_attribute(kg, sd, ATTR_STD_PTEX_FACE_ID); | ||||
| const AttributeDescriptor desc_uv = find_attribute(kg, sd, ATTR_STD_PTEX_UV); | const AttributeDescriptor desc_uv = find_attribute(kg, sd, ATTR_STD_PTEX_UV); | ||||
| if (desc_face_id.offset == ATTR_STD_NOT_FOUND || desc_uv.offset == ATTR_STD_NOT_FOUND) | if (desc_face_id.offset == ATTR_STD_NOT_FOUND || desc_uv.offset == ATTR_STD_NOT_FOUND) | ||||
| return false; | return false; | ||||
| float3 uv3 = primitive_surface_attribute_float3(kg, sd, desc_uv, NULL, NULL); | float3 uv3 = primitive_surface_attribute_float3(kg, sd, desc_uv, NULL, NULL); | ||||
| float face_id_f = primitive_surface_attribute_float(kg, sd, desc_face_id, NULL, NULL); | float face_id_f = primitive_surface_attribute_float(kg, sd, desc_face_id, NULL, NULL); | ||||
| *uv = make_float2(uv3.x, uv3.y); | *uv = make_float2(uv3.x, uv3.y); | ||||
| *face_id = (int)face_id_f; | *face_id = (int)face_id_f; | ||||
| return true; | return true; | ||||
| } | } | ||||
| /* Surface tangent */ | /* Surface tangent */ | ||||
| ccl_device float3 primitive_tangent(ccl_global const KernelGlobals *kg, ccl_private ShaderData *sd) | ccl_device float3 primitive_tangent(KernelGlobals kg, ccl_private ShaderData *sd) | ||||
| { | { | ||||
| #ifdef __HAIR__ | #ifdef __HAIR__ | ||||
| if (sd->type & PRIMITIVE_ALL_CURVE) | if (sd->type & PRIMITIVE_ALL_CURVE) | ||||
| # ifdef __DPDU__ | # ifdef __DPDU__ | ||||
| return normalize(sd->dPdu); | return normalize(sd->dPdu); | ||||
| # else | # else | ||||
| return make_float3(0.0f, 0.0f, 0.0f); | return make_float3(0.0f, 0.0f, 0.0f); | ||||
| # endif | # endif | ||||
| Show All 15 Lines | |||||
| #else | #else | ||||
| return make_float3(0.0f, 0.0f, 0.0f); | return make_float3(0.0f, 0.0f, 0.0f); | ||||
| #endif | #endif | ||||
| } | } | ||||
| } | } | ||||
| /* Motion vector for motion pass */ | /* Motion vector for motion pass */ | ||||
| ccl_device_inline float4 primitive_motion_vector(ccl_global const KernelGlobals *kg, | ccl_device_inline float4 primitive_motion_vector(KernelGlobals kg, | ||||
| ccl_private const ShaderData *sd) | ccl_private const ShaderData *sd) | ||||
| { | { | ||||
| /* center position */ | /* center position */ | ||||
| float3 center; | float3 center; | ||||
| #ifdef __HAIR__ | #ifdef __HAIR__ | ||||
| bool is_curve_primitive = sd->type & PRIMITIVE_ALL_CURVE; | bool is_curve_primitive = sd->type & PRIMITIVE_ALL_CURVE; | ||||
| if (is_curve_primitive) { | if (is_curve_primitive) { | ||||
| ▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines | |||||