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