Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/closure/bsdf_hair_principled.h
| Show First 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | ccl_device_inline float longitudinal_scattering( | ||||
| else { | else { | ||||
| float i0 = bessel_I0(cos_arg); | float i0 = bessel_I0(cos_arg); | ||||
| float val = (expf(-sin_arg) * i0) / (sinhf(inv_v) * 2.0f * v); | float val = (expf(-sin_arg) * i0) / (sinhf(inv_v) * 2.0f * v); | ||||
| return val; | return val; | ||||
| } | } | ||||
| } | } | ||||
| /* Combine the three values using their luminances. */ | /* Combine the three values using their luminances. */ | ||||
| ccl_device_inline float4 combine_with_energy(ccl_global const KernelGlobals *kg, float3 c) | ccl_device_inline float4 combine_with_energy(KernelGlobals kg, float3 c) | ||||
| { | { | ||||
| return make_float4(c.x, c.y, c.z, linear_rgb_to_gray(kg, c)); | return make_float4(c.x, c.y, c.z, linear_rgb_to_gray(kg, c)); | ||||
| } | } | ||||
| #ifdef __HAIR__ | #ifdef __HAIR__ | ||||
| /* Set up the hair closure. */ | /* Set up the hair closure. */ | ||||
| ccl_device int bsdf_principled_hair_setup(ccl_private ShaderData *sd, | ccl_device int bsdf_principled_hair_setup(ccl_private ShaderData *sd, | ||||
| ccl_private PrincipledHairBSDF *bsdf) | ccl_private PrincipledHairBSDF *bsdf) | ||||
| Show All 32 Lines | ccl_device int bsdf_principled_hair_setup(ccl_private ShaderData *sd, | ||||
| bsdf->extra->geom = make_float4(Y.x, Y.y, Y.z, h); | bsdf->extra->geom = make_float4(Y.x, Y.y, Y.z, h); | ||||
| return SD_BSDF | SD_BSDF_HAS_EVAL | SD_BSDF_NEEDS_LCG; | return SD_BSDF | SD_BSDF_HAS_EVAL | SD_BSDF_NEEDS_LCG; | ||||
| } | } | ||||
| #endif /* __HAIR__ */ | #endif /* __HAIR__ */ | ||||
| /* Given the Fresnel term and transmittance, generate the attenuation terms for each bounce. */ | /* Given the Fresnel term and transmittance, generate the attenuation terms for each bounce. */ | ||||
| ccl_device_inline void hair_attenuation(ccl_global const KernelGlobals *kg, | ccl_device_inline void hair_attenuation(KernelGlobals kg, | ||||
| float f, | float f, | ||||
| float3 T, | float3 T, | ||||
| ccl_private float4 *Ap) | ccl_private float4 *Ap) | ||||
| { | { | ||||
| /* Primary specular (R). */ | /* Primary specular (R). */ | ||||
| Ap[0] = make_float4(f, f, f, f); | Ap[0] = make_float4(f, f, f, f); | ||||
| /* Transmission (TT). */ | /* Transmission (TT). */ | ||||
| Show All 35 Lines | ccl_device_inline void hair_alpha_angles(float sin_theta_i, | ||||
| angles[1] = fabsf(cos_theta_i * cos_2alpha - sin_theta_i * sin_2alpha); | angles[1] = fabsf(cos_theta_i * cos_2alpha - sin_theta_i * sin_2alpha); | ||||
| angles[2] = sin_theta_i * cos_1alpha - cos_theta_i * sin_1alpha; | angles[2] = sin_theta_i * cos_1alpha - cos_theta_i * sin_1alpha; | ||||
| angles[3] = fabsf(cos_theta_i * cos_1alpha + sin_theta_i * sin_1alpha); | angles[3] = fabsf(cos_theta_i * cos_1alpha + sin_theta_i * sin_1alpha); | ||||
| angles[4] = sin_theta_i * cos_4alpha - cos_theta_i * sin_4alpha; | angles[4] = sin_theta_i * cos_4alpha - cos_theta_i * sin_4alpha; | ||||
| angles[5] = fabsf(cos_theta_i * cos_4alpha + sin_theta_i * sin_4alpha); | angles[5] = fabsf(cos_theta_i * cos_4alpha + sin_theta_i * sin_4alpha); | ||||
| } | } | ||||
| /* Evaluation function for our shader. */ | /* Evaluation function for our shader. */ | ||||
| ccl_device float3 bsdf_principled_hair_eval(ccl_global const KernelGlobals *kg, | ccl_device float3 bsdf_principled_hair_eval(KernelGlobals kg, | ||||
| ccl_private const ShaderData *sd, | ccl_private const ShaderData *sd, | ||||
| ccl_private const ShaderClosure *sc, | ccl_private const ShaderClosure *sc, | ||||
| const float3 omega_in, | const float3 omega_in, | ||||
| ccl_private float *pdf) | ccl_private float *pdf) | ||||
| { | { | ||||
| kernel_assert(isfinite3_safe(sd->P) && isfinite_safe(sd->ray_length)); | kernel_assert(isfinite3_safe(sd->P) && isfinite_safe(sd->ray_length)); | ||||
| ccl_private const PrincipledHairBSDF *bsdf = (ccl_private const PrincipledHairBSDF *)sc; | ccl_private const PrincipledHairBSDF *bsdf = (ccl_private const PrincipledHairBSDF *)sc; | ||||
| ▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | ccl_device float3 bsdf_principled_hair_eval(KernelGlobals kg, | ||||
| F += Ap[3] * Mp * Np; | F += Ap[3] * Mp * Np; | ||||
| kernel_assert(isfinite3_safe(float4_to_float3(F))); | kernel_assert(isfinite3_safe(float4_to_float3(F))); | ||||
| *pdf = F.w; | *pdf = F.w; | ||||
| return float4_to_float3(F); | return float4_to_float3(F); | ||||
| } | } | ||||
| /* Sampling function for the hair shader. */ | /* Sampling function for the hair shader. */ | ||||
| ccl_device int bsdf_principled_hair_sample(ccl_global const KernelGlobals *kg, | ccl_device int bsdf_principled_hair_sample(KernelGlobals kg, | ||||
| ccl_private const ShaderClosure *sc, | ccl_private const ShaderClosure *sc, | ||||
| ccl_private ShaderData *sd, | ccl_private ShaderData *sd, | ||||
| float randu, | float randu, | ||||
| float randv, | float randv, | ||||
| ccl_private float3 *eval, | ccl_private float3 *eval, | ||||
| ccl_private float3 *omega_in, | ccl_private float3 *omega_in, | ||||
| ccl_private float3 *domega_in_dx, | ccl_private float3 *domega_in_dx, | ||||
| ccl_private float3 *domega_in_dy, | ccl_private float3 *domega_in_dy, | ||||
| ▲ Show 20 Lines • Show All 158 Lines • Show Last 20 Lines | |||||