Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/geom/geom_curve_intersect.h
| Show First 20 Lines • Show All 728 Lines • ▼ Show 20 Lines | if (!(sd->type & PRIMITIVE_ALL_MOTION)) { | ||||
| P_curve[2] = kernel_tex_fetch(__curve_keys, k1); | P_curve[2] = kernel_tex_fetch(__curve_keys, k1); | ||||
| P_curve[3] = kernel_tex_fetch(__curve_keys, kb); | P_curve[3] = kernel_tex_fetch(__curve_keys, kb); | ||||
| } | } | ||||
| else { | else { | ||||
| motion_curve_keys(kg, sd->object, sd->prim, sd->time, ka, k0, k1, kb, P_curve); | motion_curve_keys(kg, sd->object, sd->prim, sd->time, ka, k0, k1, kb, P_curve); | ||||
| } | } | ||||
| sd->u = isect->u; | sd->u = isect->u; | ||||
| sd->v = isect->v; | |||||
| P = P + D * t; | P = P + D * t; | ||||
| const float4 dPdu4 = catmull_rom_basis_derivative(P_curve, isect->u); | const float4 dPdu4 = catmull_rom_basis_derivative(P_curve, isect->u); | ||||
| const float3 dPdu = float4_to_float3(dPdu4); | const float3 dPdu = float4_to_float3(dPdu4); | ||||
| if (sd->type & (PRIMITIVE_CURVE_RIBBON | PRIMITIVE_MOTION_CURVE_RIBBON)) { | if (sd->type & (PRIMITIVE_CURVE_RIBBON | PRIMITIVE_MOTION_CURVE_RIBBON)) { | ||||
| /* Rounded smooth normals for ribbons, to approximate thick curve shape. */ | /* Rounded smooth normals for ribbons, to approximate thick curve shape. */ | ||||
| const float3 tangent = normalize(dPdu); | const float3 tangent = normalize(dPdu); | ||||
| const float3 bitangent = normalize(cross(tangent, -D)); | const float3 bitangent = normalize(cross(tangent, -D)); | ||||
| const float sine = isect->v; | const float sine = isect->v; | ||||
| const float cosine = safe_sqrtf(1.0f - sine * sine); | const float cosine = safe_sqrtf(1.0f - sine * sine); | ||||
| sd->N = normalize(sine * bitangent - cosine * normalize(cross(tangent, bitangent))); | sd->N = normalize(sine * bitangent - cosine * normalize(cross(tangent, bitangent))); | ||||
| sd->Ng = -D; | sd->Ng = -D; | ||||
| sd->v = isect->v; | |||||
| # if 0 | # if 0 | ||||
| /* This approximates the position and geometric normal of a thick curve too, | /* This approximates the position and geometric normal of a thick curve too, | ||||
| * but gives too many issues with wrong self intersections. */ | * but gives too many issues with wrong self intersections. */ | ||||
| const float dPdu_radius = dPdu4.w; | const float dPdu_radius = dPdu4.w; | ||||
| sd->Ng = sd->N; | sd->Ng = sd->N; | ||||
| P += sd->N * dPdu_radius; | P += sd->N * dPdu_radius; | ||||
| # endif | # endif | ||||
| } | } | ||||
| else { | else { | ||||
| /* Thick curves, compute normal using direction from inside the curve. | /* Thick curves, compute normal using direction from inside the curve. | ||||
| * This could be optimized by recording the normal in the intersection, | * This could be optimized by recording the normal in the intersection, | ||||
| * however for Optix this would go beyond the size of the payload. */ | * however for Optix this would go beyond the size of the payload. */ | ||||
| const float3 P_inside = float4_to_float3(catmull_rom_basis_eval(P_curve, isect->u)); | const float3 P_inside = float4_to_float3(catmull_rom_basis_eval(P_curve, isect->u)); | ||||
| sd->Ng = normalize(P - P_inside); | const float3 Ng = normalize(P - P_inside); | ||||
| sd->N = sd->Ng; | |||||
| sd->N = Ng; | |||||
| sd->Ng = Ng; | |||||
| sd->v = 0.0f; | |||||
| } | } | ||||
| # ifdef __DPDU__ | # ifdef __DPDU__ | ||||
| /* dPdu/dPdv */ | /* dPdu/dPdv */ | ||||
| sd->dPdu = dPdu; | sd->dPdu = dPdu; | ||||
| sd->dPdv = cross(dPdu, sd->Ng); | sd->dPdv = cross(dPdu, sd->Ng); | ||||
| # endif | # endif | ||||
| Show All 19 Lines | |||||