Blender V5.3
bsdf_util.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009-2010 Sony Pictures Imageworks Inc., et al. All Rights Reserved.
2 * SPDX-FileCopyrightText: 2011-2022 Blender Foundation
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 * Adapted code from Open Shading Language. */
7
8#pragma once
9
10#include "kernel/types.h"
11
14
15#include "util/color.h"
16#include "util/types_spectrum.h"
17
19
21 float thickness;
22 float ior;
23};
24
25template<typename T> struct complex {
28
30 {
31 const T im = this->re * other.im + this->im * other.re;
32 this->re = this->re * other.re - this->im * other.im;
33 this->im = im;
34 return *this;
35 }
36
38 {
39 return complex<T>{this->re * other, this->im * other};
40 }
41};
42
43/* Compute fresnel reflectance for perpendicular (aka S-) and parallel (aka P-) polarized light.
44 * If requested by the caller, r_cos_phi is set to the cosine of the phase shift on reflection.
45 * Also returns the dot product of the refracted ray and the normal as `cos_theta_t`, as it is
46 * used when computing the direction of the refracted ray. */
48 const float eta,
49 ccl_private float *r_cos_theta_t,
50 ccl_private float2 *r_cos_phi)
51{
52 kernel_assert(!isnan_safe(cos_theta_i));
53
54 /* Using Snell's law, calculate the squared cosine of the angle between the surface normal and
55 * the transmitted ray. */
56 const float eta_cos_theta_t_sq = sqr(eta) - (1.0f - sqr(cos_theta_i));
57 if (eta_cos_theta_t_sq <= 0) {
58 /* Total internal reflection. */
59 if (r_cos_phi) {
60 /* The following code would compute the proper phase shift on TIR.
61 * However, for the current user of this computation (the iridescence code),
62 * this doesn't actually affect the result, so don't bother with the computation for now.
63 *
64 * `const float fac = sqrtf(1.0f - sqr(cosThetaI) - sqr(eta));`
65 * `r_phi->x = -2.0f * atanf(fac / cosThetaI);`
66 * `r_phi->y = -2.0f * atanf(fac / (cosThetaI * sqr(eta)));`
67 */
68 *r_cos_phi = one_float2();
69 }
70 return one_float2();
71 }
72
73 cos_theta_i = fabsf(cos_theta_i);
74 /* Relative to the surface normal. */
75 const float cos_theta_t = -safe_sqrtf(eta_cos_theta_t_sq) / eta;
76
77 if (r_cos_theta_t) {
78 *r_cos_theta_t = cos_theta_t;
79 }
80
81 /* Amplitudes of reflected waves. */
82 const float r_s = (cos_theta_i + eta * cos_theta_t) / (cos_theta_i - eta * cos_theta_t);
83 const float r_p = (cos_theta_t + eta * cos_theta_i) / (eta * cos_theta_i - cos_theta_t);
84
85 if (r_cos_phi) {
86 *r_cos_phi = make_float2(2 * (r_s >= 0.0f) - 1, 2 * (r_p >= 0.0f) - 1);
87 }
88
89 /* Return squared amplitude to get the fraction of reflected energy. */
90 return make_float2(sqr(r_s), sqr(r_p));
91}
92
93/* Compute fresnel reflectance for unpolarized light. */
94ccl_device_forceinline float fresnel_dielectric(const float cos_theta_i,
95 const float eta,
96 ccl_private float *r_cos_theta_t)
97{
98 return average(fresnel_dielectric_polarized(cos_theta_i, eta, r_cos_theta_t, nullptr));
99}
100
101/* Refract the incident ray, given the cosine of the refraction angle and the relative refractive
102 * index of the incoming medium w.r.t. the outgoing medium. */
104 const float3 normal,
105 const float cos_theta_t,
106 const float inv_eta)
107{
108 return (inv_eta * dot(normal, incident) + cos_theta_t) * normal - inv_eta * incident;
109}
110
111ccl_device float fresnel_dielectric_cos(const float cosi, const float eta)
112{
113 // compute fresnel reflectance without explicitly computing
114 // the refracted direction
115 const float c = fabsf(cosi);
116 float g = eta * eta - 1 + c * c;
117 if (g > 0) {
118 g = sqrtf(g);
119 const float A = (g - c) / (g + c);
120 const float B = (c * (g + c) - 1) / (c * (g - c) + 1);
121 return 0.5f * A * A * (1 + B * B);
122 }
123 return 1.0f; // TIR(no refracted component)
124}
125
126/* Approximates the average single-scattering Fresnel for a given IOR.
127 * This is defined as the integral over 0...1 of 2*cosI * F(cosI, eta) d_cosI, with F being
128 * the real dielectric Fresnel.
129 * The implementation here uses a numerical fit from "Revisiting Physically Based Shading
130 * at Imageworks" by Christopher Kulla and Alejandro Conty. */
132{
133 if (eta < 1.0f) {
134 return 0.997118f + eta * (0.1014f - eta * (0.965241f + eta * 0.130607f));
135 }
136 return (eta - 1.0f) / (4.08567f + 1.00071f * eta);
137}
138
139/* Computes the average single-scattering Fresnel for the F82 metallic model. */
141{
142 return mix(F0, one_spectrum(), 1.0f / 21.0f) - B * (1.0f / 126.0f);
143}
144
145/* Precompute the B term for the F82 metallic model, given a tint factor. */
147{
148 /* In the classic F82 model, the F82 input directly determines the value of the Fresnel
149 * model at ~82°, similar to F0 and F90.
150 * With F82-Tint, on the other hand, the value at 82° is the value of the classic Schlick
151 * model multiplied by the tint input.
152 * Therefore, the factor follows by setting F82Tint(cosI) = FSchlick(cosI) - b*cosI*(1-cosI)^6
153 * and F82Tint(acos(1/7)) = FSchlick(acos(1/7)) * f82_tint and solving for b. */
154 const float f = 6.0f / 7.0f;
155 const float f5 = sqr(sqr(f)) * f;
156 const Spectrum F_schlick = mix(F0, one_spectrum(), f5);
157 return F_schlick * (7.0f / (f5 * f)) * (one_spectrum() - tint);
158}
159
160/* Precompute the B term for the F82 metallic model, given the F82 value. */
162{
163 const float f = 6.0f / 7.0f;
164 const float f5 = sqr(sqr(f)) * f;
165 const Spectrum F_schlick = mix(F0, one_spectrum(), f5);
166 return (7.0f / (f5 * f)) * (F_schlick - F82);
167}
168
169ccl_device_inline float fresnel_f82_B(const float F0, const float F82)
170{
171 const float f = 6.0f / 7.0f;
172 const float f5 = sqr(sqr(f)) * f;
173 const float F_schlick = mix(F0, 1.0f, f5);
174 return (7.0f / (f5 * f)) * (F_schlick - F82);
175}
176
177/* Evaluate the F82 metallic model for the given parameters. */
178ccl_device_inline Spectrum fresnel_f82(const float cosi, const Spectrum F0, const Spectrum B)
179{
180 const float s = saturatef(1.0f - cosi);
181 const float s5 = sqr(sqr(s)) * s;
182 const Spectrum F_schlick = mix(F0, one_spectrum(), s5);
183 return saturate(F_schlick - B * cosi * s5 * s);
184}
185
186ccl_device_inline float fresnel_f82(const float cosi, const float F0, const float B)
187{
188 const float s = saturatef(1.0f - cosi);
189 const float s5 = sqr(sqr(s)) * s;
190 const float F_schlick = mix(F0, 1.0f, s5);
191 return clamp(F_schlick - B * cosi * s5 * s, 0.0f, 1.0f);
192}
193
194/* Evaluates the Fresnel equations at a dielectric-conductor interface, calculating reflectances
195 * and phase shifts due to reflection if requested. The phase shifts phi_s and phi_p are returned
196 * as phasor_s = exp(i * phi_s) and phasor_p = exp(i * phi_p).
197 * This code is based on equations from section 14.4.1 of Principles of Optics 7th ed. by Born and
198 * Wolf, but uses `n + ik` instead of `n(1 + ik)` for IOR. The phase shifts are calculated so that
199 * phi_p = phi_s at 90 degree incidence to match fresnel_dielectric_polarized. */
201 const float cosi,
202 const float ambient_ior,
203 const complex<float> conductor_ior,
204 const float F82,
205 ccl_private float &r_R_s,
206 ccl_private float &r_R_p,
207 ccl_private complex<float> *r_phasor_s = nullptr,
208 ccl_private complex<float> *r_phasor_p = nullptr)
209{
210 const float eta1 = ambient_ior;
211 const float eta2 = conductor_ior.re;
212 const float k2 = conductor_ior.im;
213
214 const float eta1_sq = sqr(eta1);
215 const float eta2_sq = sqr(eta2);
216 const float k2_sq = sqr(k2);
217 const float two_eta2_k2 = 2.0f * eta2 * k2;
218
219 const float t1 = eta2_sq - k2_sq - eta1_sq * (1.0f - sqr(cosi));
220 const float t2 = sqrt(sqr(t1) + sqr(two_eta2_k2));
221
222 const float u_sq = max(0.5f * (t2 + t1), 0.0f);
223 const float v_sq = max(0.5f * (t2 - t1), 0.0f);
224 const float u = sqrt(u_sq);
225 const float v = sqrt(v_sq);
226
227 if (F82 >= 0.0f) {
228 /* Calculate reflectance using the F82 model if the caller requested it. */
229 /* Scale n and k by the film ior, and recompute F0. */
230 const float n = eta2 / eta1;
231 const float k_sq = sqr(k2 / eta1);
232 const float F0 = (sqr(n - 1.0f) + k_sq) / (sqr(n + 1.0f) + k_sq);
233 r_R_s = fresnel_f82(cosi, F0, fresnel_f82_B(F0, F82));
234 r_R_p = r_R_s;
235 }
236 else {
237 r_R_s = safe_divide(sqr(eta1 * cosi - u) + v_sq, sqr(eta1 * cosi + u) + v_sq);
238
239 const float t3 = (eta2_sq - k2_sq) * cosi;
240 const float t4 = two_eta2_k2 * cosi;
241 r_R_p = safe_divide(sqr(t3 - eta1 * u) + sqr(t4 - eta1 * v),
242 sqr(t3 + eta1 * u) + sqr(t4 + eta1 * v));
243 }
244
245 if (r_phasor_s && r_phasor_p) {
246 const float re_s = -u_sq - v_sq + sqr(eta1 * cosi);
247 const float im_s = -2.0f * eta1 * cosi * v;
248 const float mag_s = sqrt(sqr(re_s) + sqr(im_s));
249 r_phasor_s->re = (mag_s == 0.0f) ? 1.0f : re_s / mag_s;
250 r_phasor_s->im = (mag_s == 0.0f) ? 0.0f : im_s / mag_s;
251
252 const float re_p = sqr((eta2_sq + k2_sq) * cosi) - eta1_sq * (u_sq + v_sq);
253 const float im_p = 2.0f * eta1 * cosi * (two_eta2_k2 * u - (eta2_sq - k2_sq) * v);
254 const float mag_p = sqrt(sqr(re_p) + sqr(im_p));
255 r_phasor_p->re = mag_p == 0.0f ? 1.0f : re_p / mag_p;
256 r_phasor_p->im = mag_p == 0.0f ? 0.0f : im_p / mag_p;
257 }
258}
259
260/* Calculates Fresnel reflectance at a dielectric-conductor interface given the relative IOR.
261 */
263{
264 float R_s_x, R_s_y, R_s_z, R_p_x, R_p_y, R_p_z;
266 cosi, 1.0f, {ior.re.x, ior.im.x}, -1.0f, R_s_x, R_p_x, nullptr, nullptr);
268 cosi, 1.0f, {ior.re.y, ior.im.y}, -1.0f, R_s_y, R_p_y, nullptr, nullptr);
270 cosi, 1.0f, {ior.re.z, ior.im.z}, -1.0f, R_s_z, R_p_z, nullptr, nullptr);
271 return (make_float3(R_s_x, R_s_y, R_s_z) + make_float3(R_p_x, R_p_y, R_p_z)) * 0.5f;
272}
273
274/* Approximates the average single-scattering Fresnel for a physical conductor. */
276{
277 /* In order to estimate Fss of the conductor, we fit the F82 model to it based on the
278 * value at 0° and ~82° and then use the analytic expression for its Fss. */
279 const Spectrum F0 = fresnel_conductor(1.0f, ior);
280 const Spectrum F82 = fresnel_conductor(1.0f / 7.0f, ior);
281 return saturate(fresnel_f82_Fss(F0, fresnel_f82_B(F0, F82)));
282}
283
284ccl_device float ior_from_F0(const float f0)
285{
286 const float sqrt_f0 = sqrtf(clamp(f0, 0.0f, 0.99f));
287 return (1.0f + sqrt_f0) / (1.0f - sqrt_f0);
288}
289
290ccl_device float F0_from_ior(const float ior)
291{
292 return sqr((ior - 1.0f) / (ior + 1.0f));
293}
294
295ccl_device float schlick_fresnel(const float u)
296{
297 const float m = clamp(1.0f - u, 0.0f, 1.0f);
298 const float m2 = m * m;
299 return m2 * m2 * m; // pow(m, 5)
300}
301
302/* Calculate the fresnel color, which is a blend between white and the F0 color */
304 const float3 H,
305 const float ior,
306 Spectrum F0)
307{
308 /* Compute the real Fresnel term and remap it from real_F0..1 to F0..1.
309 * The reason why we use this remapping instead of directly doing the
310 * Schlick approximation mix(F0, 1.0, (1.0-cosLH)^5) is that for cases
311 * with similar IORs (e.g. ice in water), the relative IOR can be close
312 * enough to 1.0 that the Schlick approximation becomes inaccurate. */
313 const float real_F = fresnel_dielectric_cos(dot(L, H), ior);
314 const float real_F0 = fresnel_dielectric_cos(1.0f, ior);
315
316 return mix(F0, one_spectrum(), inverse_lerp(real_F0, 1.0f, real_F));
317}
318
319/* If the shading normal results in specular reflection in the lower hemisphere, raise the shading
320 * normal towards the geometry normal so that the specular reflection is just above the surface.
321 * Only used for glossy materials. */
323{
324 const float3 R = 2 * dot(N, I) * N - I;
325
326 const float Iz = dot(I, Ng);
327 kernel_assert(Iz >= 0);
328
329 /* Reflection rays may always be at least as shallow as the incoming ray. */
330 const float threshold = min(0.9f * Iz, 0.01f);
331 if (dot(Ng, R) >= threshold) {
332 return N;
333 }
334
335 /* Form coordinate system with Ng as the Z axis and N inside the X-Z-plane.
336 * The X axis is found by normalizing the component of N that's orthogonal to Ng.
337 * The Y axis isn't actually needed.
338 */
339 const float3 X = safe_normalize_fallback(N - dot(N, Ng) * Ng, N);
340
341 /* Calculate N.z and N.x in the local coordinate system.
342 *
343 * The goal of this computation is to find a N' that is rotated towards Ng just enough
344 * to lift R' above the threshold (here called t), therefore dot(R', Ng) = t.
345 *
346 * According to the standard reflection equation,
347 * this means that we want dot(2*dot(N', I)*N' - I, Ng) = t.
348 *
349 * Since the Z axis of our local coordinate system is Ng, dot(x, Ng) is just x.z, so we get
350 * 2*dot(N', I)*N'.z - I.z = t.
351 *
352 * The rotation is simple to express in the coordinate system we formed -
353 * since N lies in the X-Z-plane, we know that N' will also lie in the X-Z-plane,
354 * so N'.y = 0 and therefore dot(N', I) = N'.x*I.x + N'.z*I.z .
355 *
356 * Furthermore, we want N' to be normalized, so N'.x = sqrt(1 - N'.z^2).
357 *
358 * With these simplifications, we get the equation
359 * 2*(sqrt(1 - N'.z^2)*I.x + N'.z*I.z)*N'.z - I.z = t,
360 * or
361 * 2*sqrt(1 - N'.z^2)*I.x*N'.z = t + I.z * (1 - 2*N'.z^2),
362 * after rearranging terms.
363 * Raise both sides to the power of two and substitute terms with
364 * a = I.x^2 + I.z^2,
365 * b = 2*(a + Iz*t),
366 * c = (Iz + t)^2,
367 * we obtain
368 * 4*a*N'.z^4 - 2*b*N'.z^2 + c = 0.
369 *
370 * The only unknown here is N'.z, so we can solve for that.
371 *
372 * The equation has four solutions in general, two can immediately be discarded because they're
373 * negative so N' would lie in the lower hemisphere; one solves
374 * 2*sqrt(1 - N'.z^2)*I.x*N'.z = -(t + I.z * (1 - 2*N'.z^2))
375 * instead of the original equation (before squaring both sides).
376 * Therefore only one root is valid.
377 */
378
379 const float Ix = dot(I, X);
380
381 const float a = sqr(Ix) + sqr(Iz);
382 const float b = 2.0f * (a + Iz * threshold);
383 const float c = sqr(threshold + Iz);
384
385 /* In order that the root formula solves 2*sqrt(1 - N'.z^2)*I.x*N'.z = t + I.z - 2*I.z*N'.z^2,
386 * Ix and (t + I.z * (1 - 2*N'.z^2)) must have the same sign (the rest terms are non-negative by
387 * definition). */
388 const float Nz2 = (Ix < 0) ? 0.25f * (b + safe_sqrtf(sqr(b) - 4.0f * a * c)) / a :
389 0.25f * (b - safe_sqrtf(sqr(b) - 4.0f * a * c)) / a;
390
391 const float Nx = safe_sqrtf(1.0f - Nz2);
392 const float Nz = safe_sqrtf(Nz2);
393
394 return Nx * X + Nz * Ng;
395}
396
397/* Do not call #ensure_valid_specular_reflection if the primitive type is curve or if the geometry
398 * normal and the shading normal is the same. */
400 const float3 N)
401{
402 if ((sd->shader_flag & SD_USE_BUMP_MAP_CORRECTION) == 0) {
403 return N;
404 }
405 if ((sd->type & PRIMITIVE_CURVE) || isequal(sd->Ng, N)) {
406 return N;
407 }
408 return ensure_valid_specular_reflection(sd->Ng, sd->wi, N);
409}
410
411/* Principled Hair albedo and absorption coefficients. */
413 const float azimuthal_roughness)
414{
415 const float x = azimuthal_roughness;
416 return (((((0.245f * x) + 5.574f) * x - 10.73f) * x + 2.532f) * x - 0.215f) * x + 5.969f;
417}
418
420bsdf_principled_hair_sigma_from_reflectance(const Spectrum color, const float azimuthal_roughness)
421{
422 const Spectrum sigma = log(max(color, zero_spectrum())) /
424 return sigma * sigma;
425}
426
428 const float pheomelanin)
429{
430 const float3 eumelanin_color = make_float3(0.506f, 0.841f, 1.653f);
431 const float3 pheomelanin_color = make_float3(0.343f, 0.733f, 1.924f);
432
433 return eumelanin * rgb_to_spectrum(eumelanin_color) +
434 pheomelanin * rgb_to_spectrum(pheomelanin_color);
435}
436
437/* Computes the weight for base closure(s) which are layered under another closure.
438 * layer_albedo is an estimate of the top layer's reflectivity, while weight is the closure weight
439 * of the entire base+top combination. */
441 const Spectrum weight)
442{
443 return clamp(weight - layer_albedo, zero_spectrum(), weight);
444}
445
446/* ******** Thin-film iridescence implementation ********
447 *
448 * Based on "A Practical Extension to Microfacet Theory for the Modeling of Varying Iridescence"
449 * by Laurent Belcour and Pascal Barla.
450 * https://belcour.github.io/blog/research/publication/2017/05/01/brdf-thin-film.html.
451 */
452
457 const int channel,
458 const float OPD)
459{
460 /* The LUT covers 0 to 60 um. */
461 const float x = M_2PI_F * OPD / 60000.0f;
462 const int size = THIN_FILM_TABLE_SIZE;
463 const int base = kernel_data.tables.thin_film_table;
464 return {lookup_table_read(kg, x, base + channel * size, size),
465 lookup_table_read(kg, x, base + (channel + 3) * size, size)};
466}
467
469 const int channel,
470 const float R12,
471 const float R23,
472 const float OPD,
473 const complex<float> phasor)
474{
475 const float T121 = 1.0f - R12;
476 const float R123 = R12 * R23;
477 const float r123 = sqrtf(R123);
478 const float Rs = sqr(T121) * R23 / (1.0f - R123);
479
480 /* Initialize complex number for exp(i * phi)^m, equivalent to {cos(m * phi), sin(m * phi)} as
481 * used in equation 10. */
482 complex<float> accumulator = phasor;
483
484 /* Perform summation over path order differences (equation 10). */
485 float R = Rs + R12; /* C0 */
486 float Cm = Rs - T121;
487
488 /* Truncate after m=3, higher differences have barely any impact. */
489 for (int m = 1; m < 4; m++) {
490 Cm *= r123;
491 const complex<float> S = iridescence_lookup_sensitivity_channel(kg, channel, m * OPD);
492 R += Cm * 2.0f * (accumulator.re * S.re + accumulator.im * S.im);
493 accumulator *= phasor;
494 }
495 return R;
496}
497
498template<bool conductive>
500 const int channel,
501 const float ambient_ior,
502 const FresnelThinFilm thin_film,
503 const float substrate_n,
504 const float substrate_k,
505 const float F82,
506 const float cos_theta_1,
507 ccl_private float *r_cos_theta_3)
508{
509 /* For films below 1nm, the wave-optic-based Airy summation approach no longer applies,
510 * so blend towards the case without coating. */
511 float film_ior = thin_film.ior;
512 if (thin_film.thickness < 1.0f) {
513 film_ior = mix(ambient_ior, film_ior, smoothstep(0.0f, 1.0f, thin_film.thickness));
514 }
515
516 float cos_theta_2;
517 /* The real component of exp(i * phi12), equivalent to cos(phi12). */
518 float2 phasor12_real;
519
520 /* Compute reflection at the top interface (ambient to film). */
522 cos_theta_1, film_ior / ambient_ior, &cos_theta_2, &phasor12_real);
523 if (isequal(R12, one_float2())) {
524 /* TIR at the top interface. */
525 return 1.0f;
526 }
527
528 /* Compute reflection at the bottom interface (film to substrate). */
529 float R23_s, R23_p;
530 complex<float> phasor23_s, phasor23_p;
531 if constexpr (conductive) {
532 /* Material is a conductor. */
533 fresnel_conductor_polarized(-cos_theta_2,
534 film_ior,
535 {substrate_n, substrate_k},
536 F82,
537 R23_s,
538 R23_p,
539 &phasor23_s,
540 &phasor23_p);
541 }
542 else {
543 /* Material is a dielectric. */
544 float2 phasor23_real;
546 -cos_theta_2, substrate_n / film_ior, r_cos_theta_3, &phasor23_real);
547 if (isequal(R23, one_float2())) {
548 /* TIR at the bottom interface.
549 * All the Airy summation math still simplifies to 1.0 in this case. */
550 return 1.0f;
551 }
552
553 R23_s = R23.x;
554 R23_p = R23.y;
555 phasor23_s = {phasor23_real.x, 0.0f};
556 phasor23_p = {phasor23_real.y, 0.0f};
557 }
558
559 /* Compute optical path difference inside the thin film. */
560 const float OPD = -2.0f * film_ior * thin_film.thickness * cos_theta_2;
561
562 /* Compute full phase shifts due to reflection, as a complex number exp(i * (phi23 + phi21)).
563 * This complex form avoids the atan2 and cos calls needed to directly get the phase shift. */
564 const complex<float> phasor_s = phasor23_s * -phasor12_real.x;
565 const float R_s = iridescence_airy_summation_channel(kg, channel, R12.x, R23_s, OPD, phasor_s);
566
567 /* Perform Airy summation and average the polarizations. */
568 const complex<float> phasor_p = phasor23_p * -phasor12_real.y;
569 const float R_p = iridescence_airy_summation_channel(kg, channel, R12.y, R23_p, OPD, phasor_p);
570
571 return saturatef(0.5f * (R_s + R_p));
572}
573
#define A
ccl_device_inline Spectrum fresnel_conductor_Fss(const complex< Spectrum > ior)
Definition bsdf_util.h:275
ccl_device float3 maybe_ensure_valid_specular_reflection(ccl_private ShaderData *sd, const float3 N)
Definition bsdf_util.h:399
ccl_device float schlick_fresnel(const float u)
Definition bsdf_util.h:295
ccl_device_inline Spectrum bsdf_principled_hair_sigma_from_reflectance(const Spectrum color, const float azimuthal_roughness)
Definition bsdf_util.h:420
ccl_device_forceinline void fresnel_conductor_polarized(const float cosi, const float ambient_ior, const complex< float > conductor_ior, const float F82, ccl_private float &r_R_s, ccl_private float &r_R_p, ccl_private complex< float > *r_phasor_s=nullptr, ccl_private complex< float > *r_phasor_p=nullptr)
Definition bsdf_util.h:200
ccl_device float2 fresnel_dielectric_polarized(float cos_theta_i, const float eta, ccl_private float *r_cos_theta_t, ccl_private float2 *r_cos_phi)
Definition bsdf_util.h:47
ccl_device_inline float bsdf_principled_hair_albedo_roughness_scale(const float azimuthal_roughness)
Definition bsdf_util.h:412
ccl_device_inline Spectrum fresnel_f82_B(const Spectrum F0, const Spectrum F82)
Definition bsdf_util.h:161
ccl_device_inline Spectrum fresnel_f82_Fss(const Spectrum F0, const Spectrum B)
Definition bsdf_util.h:140
ccl_device_inline float fresnel_dielectric_Fss(const float eta)
Definition bsdf_util.h:131
ccl_device float3 ensure_valid_specular_reflection(const float3 Ng, const float3 I, float3 N)
Definition bsdf_util.h:322
ccl_device_inline float iridescence_airy_summation_channel(KernelGlobals kg, const int channel, const float R12, const float R23, const float OPD, const complex< float > phasor)
Definition bsdf_util.h:468
ccl_device_inline complex< float > iridescence_lookup_sensitivity_channel(KernelGlobals kg, const int channel, const float OPD)
Definition bsdf_util.h:456
ccl_device_inline Spectrum bsdf_principled_hair_sigma_from_concentration(const float eumelanin, const float pheomelanin)
Definition bsdf_util.h:427
ccl_device_inline float3 refract_angle(const float3 incident, const float3 normal, const float cos_theta_t, const float inv_eta)
Definition bsdf_util.h:103
ccl_device_inline Spectrum fresnel_f82(const float cosi, const Spectrum F0, const Spectrum B)
Definition bsdf_util.h:178
ccl_device_forceinline Spectrum interpolate_fresnel_color(const float3 L, const float3 H, const float ior, Spectrum F0)
Definition bsdf_util.h:303
ccl_device float fresnel_iridescence_channel(KernelGlobals kg, const int channel, const float ambient_ior, const FresnelThinFilm thin_film, const float substrate_n, const float substrate_k, const float F82, const float cos_theta_1, ccl_private float *r_cos_theta_3)
Definition bsdf_util.h:499
ccl_device_inline Spectrum closure_layering_weight(const Spectrum layer_albedo, const Spectrum weight)
Definition bsdf_util.h:440
ccl_device_inline Spectrum fresnel_f82tint_B(const Spectrum F0, const Spectrum tint)
Definition bsdf_util.h:146
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
btScalar max
#define kernel_assert(cond)
#define kernel_data
#define ccl_device_forceinline
#define one_spectrum
#define zero_spectrum
#define ccl_private
#define ccl_device_inline
#define THIN_FILM_TABLE_SIZE
#define ccl_device_inline_method
#define CCL_NAMESPACE_END
#define saturatef(x)
ccl_device_forceinline float3 make_float3(const float x, const float y, const float z)
float F0_from_ior(float eta)
T smoothstep(T, T, T) RET
#define log
float dot(VecOp< float, D >, VecOp< float, D >) RET
#define sqrt
constexpr T clamp(T, U, U) RET
float fresnel_dielectric_cos(float cosi, float eta)
float fresnel_dielectric(float3 Incoming, float3 Normal, float eta)
float3 fresnel_conductor(float cosi, float3 eta, float3 k)
float ior_from_F0(const float F0)
float safe_divide(float a, float b)
float average(float2 a)
@ SD_USE_BUMP_MAP_CORRECTION
@ PRIMITIVE_CURVE
ccl_device_inline Spectrum rgb_to_spectrum(const float3 rgb)
CCL_NAMESPACE_BEGIN ccl_device float lookup_table_read(KernelGlobals kg, float x, const int offset, const int size)
ccl_device_inline bool isnan_safe(const float f)
Definition math_base.h:356
ccl_device_inline float safe_sqrtf(const float f)
Definition math_base.h:571
ccl_device_inline float inverse_lerp(const float a, const float b, const float x)
Definition math_base.h:554
ccl_device_inline float2 one_float2()
Definition math_float2.h:18
ccl_device_inline bool isequal(const float2 a, const float2 b)
ccl_device_inline float3 safe_normalize_fallback(const float3 a, const float3 fallback)
#define N
#define T
#define B
#define R
#define L
#define H(x, y, z)
#define X(TYPE)
#define I
#define mix
#define sqr
#define fabsf
#define sqrtf
#define ccl_device
#define M_2PI_F
#define make_float2
#define saturate(a)
Definition smaa.cc:319
#define min(a, b)
Definition sort.cc:38
ccl_device_inline_method complex< T > operator*(ccl_private const float &other)
Definition bsdf_util.h:37
ccl_device_inline_method complex< T > operator*=(ccl_private const complex< T > &other)
Definition bsdf_util.h:29
float x
float y
float3 Spectrum