27 bsdf->roughness2 =
clamp(bsdf->roughness2, 0.001f, 1.0f);
34 bsdf->roughness1 =
clamp(bsdf->roughness1, 0.001f, 1.0f);
35 bsdf->roughness2 =
clamp(bsdf->roughness2, 0.001f, 1.0f);
45 if (
dot(bsdf->N, wo) < 0.0f) {
50 float offset = bsdf->offset;
52 float roughness1 = bsdf->roughness1;
53 float roughness2 = bsdf->roughness2;
55 float Iz =
dot(Tg, wi);
60 float wo_z =
dot(Tg, wo);
64 float cosphi_i =
dot(wo_y, locy);
71 float roughness1_inv = 1.0f / roughness1;
72 float roughness2_inv = 1.0f / roughness2;
73 float phi_i =
fast_acosf(cosphi_i) * roughness2_inv;
80 float theta_h = (theta_i + theta_r) * 0.5f;
81 float t = theta_h - offset;
83 float phi_pdf =
fast_cosf(phi_i * 0.5f) * 0.25f * roughness2_inv;
84 float theta_pdf = roughness1 /
85 (2 * (t * t + roughness1 * roughness1) * (a_R - b_R) * costheta_i);
86 *pdf = phi_pdf * theta_pdf;
97 if (
dot(bsdf->N, wo) >= 0.0f) {
102 float offset = bsdf->offset;
104 float roughness1 = bsdf->roughness1;
105 float roughness2 = bsdf->roughness2;
106 float Iz =
dot(Tg, wi);
111 float wo_z =
dot(Tg, wo);
124 float roughness1_inv = 1.0f / roughness1;
129 float theta_h = (theta_i + theta_r) / 2;
130 float t = theta_h - offset;
131 float phi =
fabsf(phi_i);
134 float theta_pdf = roughness1 /
135 (2 * (t * t + roughness1 * roughness1) * (a_TT - b_TT) * costheta_i);
136 float phi_pdf = roughness2 / (c_TT * (p * p + roughness2 * roughness2));
138 *pdf = phi_pdf * theta_pdf;
152 float offset = bsdf->
offset;
154 float roughness1 = bsdf->roughness1;
155 float roughness2 = bsdf->roughness2;
156 *sampled_roughness =
make_float2(roughness1, roughness2);
157 float Iz =
dot(Tg, wi);
162 float roughness1_inv = 1.0f / roughness1;
166 float t = roughness1 *
tanf(rand.
x * (a_R - b_R) + b_R);
168 float theta_h = t + offset;
169 float theta_i = 2 * theta_h - theta_r;
171 float costheta_i, sintheta_i;
174 float phi = 2 *
safe_asinf(1 - 2 * rand.
y) * roughness2;
176 float phi_pdf =
fast_cosf(phi * 0.5f) * 0.25f / roughness2;
178 float theta_pdf = roughness1 /
179 (2 * (t * t + roughness1 * roughness1) * (a_R - b_R) * costheta_i);
181 float sinphi, cosphi;
183 *wo = (cosphi * costheta_i) * locy - (sinphi * costheta_i) * locx + (sintheta_i)*Tg;
185 *pdf =
fabsf(phi_pdf * theta_pdf);
204 float offset = bsdf->
offset;
206 float roughness1 = bsdf->roughness1;
207 float roughness2 = bsdf->roughness2;
208 *sampled_roughness =
make_float2(roughness1, roughness2);
209 float Iz =
dot(Tg, wi);
214 float roughness1_inv = 1.0f / roughness1;
219 float t = roughness1 *
tanf(rand.
x * (a_TT - b_TT) + b_TT);
221 float theta_h = t + offset;
222 float theta_i = 2 * theta_h - theta_r;
224 float costheta_i, sintheta_i;
227 float p = roughness2 *
tanf(c_TT * (rand.
y - 0.5f));
229 float theta_pdf = roughness1 /
230 (2 * (t * t + roughness1 * roughness1) * (a_TT - b_TT) * costheta_i);
231 float phi_pdf = roughness2 / (c_TT * (p * p + roughness2 * roughness2));
233 float sinphi, cosphi;
235 *wo = (cosphi * costheta_i) * locy - (sinphi * costheta_i) * locx + (sintheta_i)*Tg;
237 *pdf =
fabsf(phi_pdf * theta_pdf);
MINLINE float safe_asinf(float a)
ccl_device int bsdf_hair_transmission_sample(ccl_private const ShaderClosure *sc, float3 Ng, float3 wi, float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf, ccl_private float2 *sampled_roughness)
ccl_device Spectrum bsdf_hair_transmission_eval(ccl_private const ShaderClosure *sc, const float3 wi, const float3 wo, ccl_private float *pdf)
ccl_device int bsdf_hair_reflection_setup(ccl_private HairBsdf *bsdf)
ccl_device Spectrum bsdf_hair_reflection_eval(ccl_private const ShaderClosure *sc, const float3 wi, const float3 wo, ccl_private float *pdf)
ccl_device int bsdf_hair_reflection_sample(ccl_private const ShaderClosure *sc, float3 Ng, float3 wi, float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf, ccl_private float2 *sampled_roughness)
ccl_device int bsdf_hair_transmission_setup(ccl_private HairBsdf *bsdf)
CCL_NAMESPACE_BEGIN struct HairBsdf HairBsdf
SIMD_FORCE_INLINE btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
additional_info("compositor_sum_squared_difference_float_shared") .push_constant(Type output_img float dot(value.rgb, luminance_coefficients)") .define("LOAD(value)"
#define kernel_assert(cond)
#define CCL_NAMESPACE_END
@ CLOSURE_BSDF_HAIR_TRANSMISSION_ID
@ CLOSURE_BSDF_HAIR_REFLECTION_ID
@ SD_BSDF_HAS_TRANSMISSION
ccl_device void fast_sincosf(float x, ccl_private float *sine, ccl_private float *cosine)
ccl_device float fast_acosf(float x)
ccl_device float fast_atan2f(float y, float x)
ccl_device float fast_cosf(float x)
ccl_device_inline float cross(const float2 a, const float2 b)
SPECTRUM_DATA_TYPE Spectrum
ccl_device_inline int clamp(int a, int mn, int mx)