Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/geom/geom_curve.h
| Show All 21 Lines | |||||
| * ribbons or curves with actual thickness. The curve can also be rendered as | * ribbons or curves with actual thickness. The curve can also be rendered as | ||||
| * line segments rather than curves for better performance. | * line segments rather than curves for better performance. | ||||
| */ | */ | ||||
| #ifdef __HAIR__ | #ifdef __HAIR__ | ||||
| /* Reading attributes on various curve elements */ | /* Reading attributes on various curve elements */ | ||||
| ccl_device float curve_attribute_float(ccl_global const KernelGlobals *kg, | ccl_device float curve_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 (desc.element & (ATTR_ELEMENT_CURVE_KEY | ATTR_ELEMENT_CURVE_KEY_MOTION)) { | if (desc.element & (ATTR_ELEMENT_CURVE_KEY | ATTR_ELEMENT_CURVE_KEY_MOTION)) { | ||||
| KernelCurve curve = kernel_tex_fetch(__curves, sd->prim); | KernelCurve curve = kernel_tex_fetch(__curves, sd->prim); | ||||
| int k0 = curve.first_key + PRIMITIVE_UNPACK_SEGMENT(sd->type); | int k0 = curve.first_key + PRIMITIVE_UNPACK_SEGMENT(sd->type); | ||||
| Show All 25 Lines | if (desc.element & (ATTR_ELEMENT_CURVE | ATTR_ELEMENT_OBJECT | ATTR_ELEMENT_MESH)) { | ||||
| return kernel_tex_fetch(__attributes_float, offset); | return kernel_tex_fetch(__attributes_float, offset); | ||||
| } | } | ||||
| else { | else { | ||||
| return 0.0f; | return 0.0f; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ccl_device float2 curve_attribute_float2(ccl_global const KernelGlobals *kg, | ccl_device float2 curve_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 (desc.element & (ATTR_ELEMENT_CURVE_KEY | ATTR_ELEMENT_CURVE_KEY_MOTION)) { | if (desc.element & (ATTR_ELEMENT_CURVE_KEY | ATTR_ELEMENT_CURVE_KEY_MOTION)) { | ||||
| KernelCurve curve = kernel_tex_fetch(__curves, sd->prim); | KernelCurve curve = kernel_tex_fetch(__curves, sd->prim); | ||||
| int k0 = curve.first_key + PRIMITIVE_UNPACK_SEGMENT(sd->type); | int k0 = curve.first_key + PRIMITIVE_UNPACK_SEGMENT(sd->type); | ||||
| Show All 29 Lines | if (desc.element & (ATTR_ELEMENT_CURVE | ATTR_ELEMENT_OBJECT | ATTR_ELEMENT_MESH)) { | ||||
| return kernel_tex_fetch(__attributes_float2, offset); | return kernel_tex_fetch(__attributes_float2, offset); | ||||
| } | } | ||||
| else { | else { | ||||
| return make_float2(0.0f, 0.0f); | return make_float2(0.0f, 0.0f); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ccl_device float3 curve_attribute_float3(ccl_global const KernelGlobals *kg, | ccl_device float3 curve_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 (desc.element & (ATTR_ELEMENT_CURVE_KEY | ATTR_ELEMENT_CURVE_KEY_MOTION)) { | if (desc.element & (ATTR_ELEMENT_CURVE_KEY | ATTR_ELEMENT_CURVE_KEY_MOTION)) { | ||||
| KernelCurve curve = kernel_tex_fetch(__curves, sd->prim); | KernelCurve curve = kernel_tex_fetch(__curves, sd->prim); | ||||
| int k0 = curve.first_key + PRIMITIVE_UNPACK_SEGMENT(sd->type); | int k0 = curve.first_key + PRIMITIVE_UNPACK_SEGMENT(sd->type); | ||||
| Show All 25 Lines | if (desc.element & (ATTR_ELEMENT_CURVE | ATTR_ELEMENT_OBJECT | ATTR_ELEMENT_MESH)) { | ||||
| return float4_to_float3(kernel_tex_fetch(__attributes_float3, offset)); | return float4_to_float3(kernel_tex_fetch(__attributes_float3, offset)); | ||||
| } | } | ||||
| else { | else { | ||||
| return make_float3(0.0f, 0.0f, 0.0f); | return make_float3(0.0f, 0.0f, 0.0f); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ccl_device float4 curve_attribute_float4(ccl_global const KernelGlobals *kg, | ccl_device float4 curve_attribute_float4(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 (desc.element & (ATTR_ELEMENT_CURVE_KEY | ATTR_ELEMENT_CURVE_KEY_MOTION)) { | if (desc.element & (ATTR_ELEMENT_CURVE_KEY | ATTR_ELEMENT_CURVE_KEY_MOTION)) { | ||||
| KernelCurve curve = kernel_tex_fetch(__curves, sd->prim); | KernelCurve curve = kernel_tex_fetch(__curves, sd->prim); | ||||
| int k0 = curve.first_key + PRIMITIVE_UNPACK_SEGMENT(sd->type); | int k0 = curve.first_key + PRIMITIVE_UNPACK_SEGMENT(sd->type); | ||||
| Show All 27 Lines | # endif | ||||
| else { | else { | ||||
| return make_float4(0.0f, 0.0f, 0.0f, 0.0f); | return make_float4(0.0f, 0.0f, 0.0f, 0.0f); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Curve thickness */ | /* Curve thickness */ | ||||
| ccl_device float curve_thickness(ccl_global const KernelGlobals *kg, | ccl_device float curve_thickness(KernelGlobals kg, ccl_private const ShaderData *sd) | ||||
| ccl_private const ShaderData *sd) | |||||
| { | { | ||||
| float r = 0.0f; | float r = 0.0f; | ||||
| if (sd->type & PRIMITIVE_ALL_CURVE) { | if (sd->type & PRIMITIVE_ALL_CURVE) { | ||||
| KernelCurve curve = kernel_tex_fetch(__curves, sd->prim); | KernelCurve curve = kernel_tex_fetch(__curves, sd->prim); | ||||
| int k0 = curve.first_key + PRIMITIVE_UNPACK_SEGMENT(sd->type); | int k0 = curve.first_key + PRIMITIVE_UNPACK_SEGMENT(sd->type); | ||||
| int k1 = k0 + 1; | int k1 = k0 + 1; | ||||
| Show All 11 Lines | ccl_device float curve_thickness(KernelGlobals kg, ccl_private const ShaderData *sd) | ||||
| } | } | ||||
| return r * 2.0f; | return r * 2.0f; | ||||
| } | } | ||||
| /* Curve location for motion pass, linear interpolation between keys and | /* Curve location for motion pass, linear interpolation between keys and | ||||
| * ignoring radius because we do the same for the motion keys */ | * ignoring radius because we do the same for the motion keys */ | ||||
| ccl_device float3 curve_motion_center_location(ccl_global const KernelGlobals *kg, | ccl_device float3 curve_motion_center_location(KernelGlobals kg, ccl_private const ShaderData *sd) | ||||
| ccl_private const ShaderData *sd) | |||||
| { | { | ||||
| KernelCurve curve = kernel_tex_fetch(__curves, sd->prim); | KernelCurve curve = kernel_tex_fetch(__curves, sd->prim); | ||||
| int k0 = curve.first_key + PRIMITIVE_UNPACK_SEGMENT(sd->type); | int k0 = curve.first_key + PRIMITIVE_UNPACK_SEGMENT(sd->type); | ||||
| int k1 = k0 + 1; | int k1 = k0 + 1; | ||||
| float4 P_curve[2]; | float4 P_curve[2]; | ||||
| P_curve[0] = kernel_tex_fetch(__curve_keys, k0); | P_curve[0] = kernel_tex_fetch(__curve_keys, k0); | ||||
| P_curve[1] = kernel_tex_fetch(__curve_keys, k1); | P_curve[1] = kernel_tex_fetch(__curve_keys, k1); | ||||
| return float4_to_float3(P_curve[1]) * sd->u + float4_to_float3(P_curve[0]) * (1.0f - sd->u); | return float4_to_float3(P_curve[1]) * sd->u + float4_to_float3(P_curve[0]) * (1.0f - sd->u); | ||||
| } | } | ||||
| /* Curve tangent normal */ | /* Curve tangent normal */ | ||||
| ccl_device float3 curve_tangent_normal(ccl_global const KernelGlobals *kg, | ccl_device float3 curve_tangent_normal(KernelGlobals kg, ccl_private const ShaderData *sd) | ||||
| ccl_private const ShaderData *sd) | |||||
| { | { | ||||
| float3 tgN = make_float3(0.0f, 0.0f, 0.0f); | float3 tgN = make_float3(0.0f, 0.0f, 0.0f); | ||||
| if (sd->type & PRIMITIVE_ALL_CURVE) { | if (sd->type & PRIMITIVE_ALL_CURVE) { | ||||
| tgN = -(-sd->I - sd->dPdu * (dot(sd->dPdu, -sd->I) / len_squared(sd->dPdu))); | tgN = -(-sd->I - sd->dPdu * (dot(sd->dPdu, -sd->I) / len_squared(sd->dPdu))); | ||||
| tgN = normalize(tgN); | tgN = normalize(tgN); | ||||
| ▲ Show 20 Lines • Show All 72 Lines • Show Last 20 Lines | |||||