Blender V5.3
bsdf.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7// clang-format off
23// clang-format on
24
26
27/* Returns the square of the roughness of the closure if it has roughness,
28 * 0 for singular closures and 1 otherwise. */
30{
31 if (CLOSURE_IS_BSDF_SINGULAR(sc->type)) {
32 return 0.0f;
33 }
34
35 if (CLOSURE_IS_BSDF_MICROFACET(sc->type)) {
37 return bsdf->alpha_x * bsdf->alpha_y;
38 }
39
40 return 1.0f;
41}
42
44{
47 return sqr(sqr(bsdf->param.roughness));
48 }
49
50 /* For the Principled BSDF, we want the Roughness pass to return the value that
51 * was set in the node. However, this value doesn't affect all closures (e.g.
52 * diffuse), so skip those that don't really have a concept of roughness. */
53 if (CLOSURE_IS_BSDF_DIFFUSE(sc->type)) {
54 return -1.0f;
55 }
56
58}
59
60/* Widen the compact ray differential dD after a non-specular bounce so that
61 * texture mip selection on subsequent hits reflects the BSDF lobe's angular
62 * spread. This significantly save memory, and is needed to make image cache
63 * memory usage scale with render tile size rather than overall resolution.
64 *
65 * This must be done consistently between next event estimation and forward
66 * sampling for both to converge to the same result for MIS. This is not just
67 * a theoretical concern, but can otherwise lead to seams.
68 *
69 * To achieve that, the sampled roughness is computed as a MIS weighted
70 * average. This makes it so directions with high contribution from sharp
71 * BSDFs have a lower roughness, as they will have a high MIS weight.
72 *
73 * The amount of widening is scaled by Filter Glossy, which is the setting
74 * to control how much caustics are blurred out. For accurate caustics
75 * image texture lookups and bump ray differentials must be small enough
76 * to capture detail at secondary bounces. */
78 const float prev_dD,
79 const float avg_roughness_squared)
80{
81 if (!(avg_roughness_squared > 0.0f)) {
82 return prev_dD;
83 }
84
85 const float scale = kernel_data.integrator.differential_widen_scale;
86 return max(prev_dD, scale * sqrtf(avg_roughness_squared));
87}
88
89/* An additional term to smooth illumination on grazing angles when using bump mapping
90 * based on "A Microfacet-Based Shadowing Function to Solve the Bump Terminator Problem"
91 * by Alejandro Conty Estevez, Pascal Lecocq, and Clifford Stein. It preserves detail
92 * close to the shadow terminator, and doesn't "wash out" intermediate bumps using a
93 * Cook-Torrance GGX function for shading. */
95 const ccl_private ShaderClosure *sc,
96 const float3 I,
97 const bool is_eval)
98{
99 if (isequal(sc->N, sd->N)) {
100 return 1.0f;
101 }
102
103 /* Smoothing doesn't apply to curve geometry. */
104 if (sd->type & PRIMITIVE_CURVE) {
105 return 1.0f;
106 }
107
108 /* In order to avoid artifacts at the shadow terminator when using smooth normals,
109 * the BSDF evaluation functions allow for light leaking through the actual geometry
110 * and only checks that the directions are in the correct hemisphere w.r.t. the
111 * shading normal.
112 * However, when using bump/normal mapping, this can lead to light leaking not just
113 * "around" the shadow terminator, but to the rear side of supposedly opaque geometry.
114 * In order to detect this case, we can ensure that the direction is also valid w.r.t.
115 * the smoothed (but non-bump-mapped) normal `sd->N` (or `Ns` for short below).
116 *
117 * `dot(Ns, I) * dot(Ns, N)` tells us if I and N are on the same side of the smoothed geometry.
118 * If incoming(I) and normal(N) are on the same side we reject refractions, `dot(N, I) < 0`.
119 * If they are on different sides we reject reflections, `dot(N, I) > 0`. */
120 const float cosNsI = dot(sd->N, I);
121 const float cosNsN = dot(sd->N, sc->N);
122 const float cosNI = dot(sc->N, I);
123 const bool is_diffuse = CLOSURE_IS_BSDF_DIFFUSE(sc->type);
124 if (cosNsI * cosNsN * cosNI < 0.0f && (is_eval || is_diffuse)) {
125 return 0.0f;
126 }
127
128 /* The above test applies to all closures, but the softening only applies to diffuse ones. */
129 if (!is_diffuse) {
130 return 1.0f;
131 }
132
133 /* When bump map correction is not used do skip the smoothing. */
134 if ((sd->shader_flag & SD_USE_BUMP_MAP_CORRECTION) == 0) {
135 return 1.0f;
136 }
137
138 /* Get absolute incoming and shader normal deviation from smoothed normal, then clamp. */
139 const float cos_i = fabsf(cosNsI);
140 const float cos_d = fabsf(cosNsN);
141 if (cos_d >= 1.0f || cos_i >= 1.0f) {
142 return 1.0f;
143 }
144 if (cos_i < 1e-6f) {
145 return 0.0f;
146 }
147
148 /* Get GGX shading values for final smoothing. */
149 const float tan2_d = 1.0f / sqr(cos_d) - 1.0f;
150 const float bump_alpha2 = saturatef(0.125f * tan2_d);
151
152 /* Return smoothed value to avoid discontinuity at perpendicular angle. */
153 return bsdf_G<MicrofacetType::GGX>(bump_alpha2, cos_i);
154}
155
156ccl_device_inline float shift_cos_in(float cos_in, const float frequency_multiplier)
157{
158 /* Shadow terminator workaround, taken from Appleseed.
159 * SPDX-License-Identifier: MIT
160 * Copyright (c) 2019 Francois Beaune, The appleseedhq Organization */
161 cos_in = min(cos_in, 1.0f);
162
163 const float angle = fast_acosf(cos_in);
164 const float val = max(cosf(angle * frequency_multiplier), 0.0f) / cos_in;
165 return val;
166}
167
168ccl_device_inline bool bsdf_is_transmission(const ccl_private ShaderClosure *sc, const float3 wo)
169{
170 return dot(sc->N, wo) < 0.0f;
171}
172
174 ccl_private ShaderData *sd,
175 const ccl_private ShaderClosure *sc,
176 const float3 rand,
177 ccl_private Spectrum *eval,
179 ccl_private float *pdf,
180 ccl_private float2 *sampled_roughness,
181 ccl_private float *eta)
182{
183 /* For curves use the smooth normal, particularly for ribbons the geometric
184 * normal gives too much darkening otherwise. */
185 *eval = zero_spectrum();
186 *pdf = 0.f;
187 int label = LABEL_NONE;
188 const float3 Ng = (sd->type & PRIMITIVE_CURVE) ? sc->N : sd->Ng;
189 const float2 rand_xy = make_float2(rand);
190
191 switch (sc->type) {
193 label = bsdf_diffuse_sample(sc, Ng, sd->wi, rand_xy, eval, wo, pdf);
194 *sampled_roughness = one_float2();
195 *eta = 1.0f;
196 break;
197#if defined(__SVM__) || defined(__OSL__)
200 sc, Ng, sd->wi, rand_xy, eval, wo, pdf, sampled_roughness, eta);
201 break;
204 sc, Ng, sd->wi, rand_xy, eval, wo, pdf, sampled_roughness, eta);
205 break;
206# ifdef __OSL__
208 label = bsdf_burley_sample(sc, Ng, sd->wi, rand_xy, eval, wo, pdf);
209 *sampled_roughness = one_float2();
210 *eta = 1.0f;
211 break;
213 label = bsdf_phong_ramp_sample(sc, Ng, sd->wi, rand_xy, eval, wo, pdf, sampled_roughness);
214 *eta = 1.0f;
215 break;
217 label = bsdf_diffuse_ramp_sample(sc, Ng, sd->wi, rand_xy, eval, wo, pdf);
218 *sampled_roughness = one_float2();
219 *eta = 1.0f;
220 break;
221# endif
223 label = bsdf_translucent_sample(sc, Ng, sd->wi, rand_xy, eval, wo, pdf);
224 *sampled_roughness = one_float2();
225 *eta = 1.0f;
226 break;
228 label = bsdf_transparent_sample(sc, Ng, sd->wi, eval, wo, pdf);
229 *sampled_roughness = zero_float2();
230 *eta = 1.0f;
231 break;
233 /* ray portals are not handled by the BSDF code, we should never get here */
234 kernel_assert(false);
235 break;
240 kg, sc, Ng, sd->wi, rand, eval, wo, pdf, sampled_roughness, eta);
241 break;
244 kg, sc, Ng, sd->wi, rand, eval, wo, pdf, sampled_roughness, eta);
245 break;
250 kg, sc, Ng, sd->wi, rand, eval, wo, pdf, sampled_roughness, eta);
251 break;
254 sc, Ng, sd->wi, rand_xy, eval, wo, pdf, sampled_roughness);
255 *eta = 1.0f;
256 break;
258 label = bsdf_ashikhmin_velvet_sample(sc, Ng, sd->wi, rand_xy, eval, wo, pdf);
259 *sampled_roughness = one_float2();
260 *eta = 1.0f;
261 break;
263 label = bsdf_diffuse_toon_sample(sc, Ng, sd->wi, rand_xy, eval, wo, pdf);
264 *sampled_roughness = one_float2();
265 *eta = 1.0f;
266 break;
268 label = bsdf_glossy_toon_sample(sc, Ng, sd->wi, rand_xy, eval, wo, pdf);
269 // double check if this is valid
270 *sampled_roughness = one_float2();
271 *eta = 1.0f;
272 break;
275 sc, Ng, sd->wi, rand_xy, eval, wo, pdf, sampled_roughness);
276 *eta = 1.0f;
277 break;
280 sc, Ng, sd->wi, rand_xy, eval, wo, pdf, sampled_roughness);
281 *eta = 1.0f;
282 break;
283# ifdef __PRINCIPLED_HAIR__
285 label = bsdf_hair_chiang_sample(kg, sc, sd, rand, eval, wo, pdf, sampled_roughness);
286 *eta = 1.0f;
287 break;
289 label = bsdf_hair_huang_sample(kg, sc, sd, rand, eval, wo, pdf, sampled_roughness);
290 *eta = 1.0f;
291 break;
292# endif
294 label = bsdf_sheen_sample(sc, Ng, sd->wi, rand_xy, eval, wo, pdf);
295 *sampled_roughness = one_float2();
296 *eta = 1.0f;
297 break;
298#endif
299 default:
300 label = LABEL_NONE;
301 break;
302 }
303
304 /* Test if BSDF sample should be treated as transparent for background. */
305 if (label & LABEL_TRANSMIT) {
306 const float threshold_squared = kernel_data.background.transparent_roughness_squared_threshold;
307
308 if (threshold_squared >= 0.0f && !(label & LABEL_DIFFUSE)) {
309 if (bsdf_get_specular_roughness_squared(sc) <= threshold_squared) {
311 }
312 }
313 }
314 else if (label != LABEL_NONE) {
315 /* Shadow terminator offset. */
316 const float frequency_multiplier =
317 kernel_data_fetch(objects, sd->object).shadow_terminator_shading_offset;
318 if (frequency_multiplier > 1.0f) {
319 const float cosNO = dot(*wo, sc->N);
320 *eval *= shift_cos_in(cosNO, frequency_multiplier);
321 }
322 *eval *= bump_shadowing_term(sd, sc, *wo, false);
323 }
324
325#ifdef WITH_CYCLES_DEBUG
326 kernel_assert(*pdf >= 0.0f);
327 kernel_assert(eval->x >= 0.0f && eval->y >= 0.0f && eval->z >= 0.0f);
328#endif
329
330 return label;
331}
332
334 const float3 wo,
335 ccl_private float2 *roughness,
336 ccl_private float *eta)
337{
338#ifdef __SVM__
339 float alpha = 1.0f;
340#endif
341 switch (sc->type) {
343 *roughness = one_float2();
344 *eta = 1.0f;
345 break;
346#ifdef __SVM__
349 *roughness = one_float2();
350 *eta = 1.0f;
351 break;
352# ifdef __OSL__
354 *roughness = one_float2();
355 *eta = 1.0f;
356 break;
358 alpha = phong_ramp_exponent_to_roughness(((const ccl_private PhongRampBsdf *)sc)->exponent);
359 *roughness = make_float2(alpha, alpha);
360 *eta = 1.0f;
361 break;
363 *roughness = one_float2();
364 *eta = 1.0f;
365 break;
366# endif
368 *roughness = one_float2();
369 *eta = 1.0f;
370 break;
373 *roughness = zero_float2();
374 *eta = 1.0f;
375 break;
383 const ccl_private MicrofacetBsdf *bsdf = (const ccl_private MicrofacetBsdf *)sc;
384 *roughness = make_float2(bsdf->alpha_x, bsdf->alpha_y);
385 *eta = (bsdf_is_transmission(sc, wo)) ? bsdf->ior : 1.0f;
386 break;
387 }
389 const ccl_private MicrofacetBsdf *bsdf = (const ccl_private MicrofacetBsdf *)sc;
390 *roughness = make_float2(bsdf->alpha_x, bsdf->alpha_y);
391 *eta = 1.0f;
392 break;
393 }
395 *roughness = one_float2();
396 *eta = 1.0f;
397 break;
399 *roughness = one_float2();
400 *eta = 1.0f;
401 break;
403 // double check if this is valid
404 *roughness = one_float2();
405 *eta = 1.0f;
406 break;
408 *roughness = make_float2(((ccl_private HairBsdf *)sc)->roughness1,
409 ((ccl_private HairBsdf *)sc)->roughness2);
410 *eta = 1.0f;
411 break;
413 *roughness = make_float2(((ccl_private HairBsdf *)sc)->roughness1,
414 ((ccl_private HairBsdf *)sc)->roughness2);
415 *eta = 1.0f;
416 break;
417# ifdef __PRINCIPLED_HAIR__
419 alpha = ((ccl_private ChiangHairBSDF *)sc)->m0_roughness;
420 *roughness = make_float2(alpha, alpha);
421 *eta = 1.0f;
422 break;
424 alpha = ((ccl_private HuangHairBSDF *)sc)->roughness;
425 *roughness = make_float2(alpha, alpha);
426 *eta = 1.0f;
427 break;
428# endif
430 alpha = ((ccl_private SheenBsdf *)sc)->roughness;
431 *roughness = make_float2(alpha, alpha);
432 *eta = 1.0f;
433 break;
434#endif
435 default:
436 *roughness = one_float2();
437 *eta = 1.0f;
438 break;
439 }
440}
441
443 const ccl_private ShaderClosure *sc,
444 const float3 wo)
445{
446 /* For curves use the smooth normal, particularly for ribbons the geometric
447 * normal gives too much darkening otherwise. */
448 int label;
449 switch (sc->type) {
456 break;
457#ifdef __SVM__
460 break;
461# ifdef __OSL__
464 break;
466 label = LABEL_REFLECT | LABEL_GLOSSY;
467 break;
470 break;
471# endif
475 break;
478 break;
481 break;
488 const ccl_private MicrofacetBsdf *bsdf = (const ccl_private MicrofacetBsdf *)sc;
489 label = ((bsdf_is_transmission(sc, wo)) ? LABEL_TRANSMIT : LABEL_REFLECT) |
491 break;
492 }
495 break;
497 label = LABEL_REFLECT | LABEL_GLOSSY;
498 break;
501 break;
504 break;
506 label = LABEL_REFLECT | LABEL_GLOSSY;
507 break;
509 label = LABEL_REFLECT | LABEL_GLOSSY;
510 break;
513 break;
514# ifdef __PRINCIPLED_HAIR__
516 if (bsdf_is_transmission(sc, wo)) {
518 }
519 else {
520 label = LABEL_REFLECT | LABEL_GLOSSY;
521 }
522 break;
524 label = LABEL_REFLECT | LABEL_GLOSSY;
525 break;
526# endif
529 break;
530#endif
531 default:
532 label = LABEL_NONE;
533 break;
534 }
535
536 /* Test if BSDF sample should be treated as transparent for background. */
537 if (label & LABEL_TRANSMIT) {
538 const float threshold_squared = kernel_data.background.transparent_roughness_squared_threshold;
539
540 if (threshold_squared >= 0.0f) {
541 if (bsdf_get_specular_roughness_squared(sc) <= threshold_squared) {
543 }
544 }
545 }
546 return label;
547}
548
549#ifndef __KERNEL_CUDA__
551#else
553#endif
555 ccl_private ShaderData *sd,
556 const ccl_private ShaderClosure *sc,
557 const float3 wo,
558 ccl_private float *pdf)
559{
560 Spectrum eval = zero_spectrum();
561 *pdf = 0.f;
562
563 const float bump_shadowing = bump_shadowing_term(sd, sc, wo, true);
564 if (bump_shadowing == 0.0f) {
565 return zero_spectrum();
566 }
567
568 switch (sc->type) {
570 eval = bsdf_diffuse_eval(sc, sd->wi, wo, pdf);
571 break;
572#if defined(__SVM__) || defined(__OSL__)
574 eval = bsdf_oren_nayar_eval(sc, sd->wi, wo, pdf);
575 break;
577 eval = bsdf_rough_translucent_eval(sc, sd->wi, wo, pdf);
578 break;
579# ifdef __OSL__
581 eval = bsdf_burley_eval(sc, sd->wi, wo, pdf);
582 break;
584 eval = bsdf_phong_ramp_eval(sc, sd->wi, wo, pdf);
585 break;
587 eval = bsdf_diffuse_ramp_eval(sc, sd->wi, wo, pdf);
588 break;
589# endif
591 eval = bsdf_translucent_eval(sc, sd->wi, wo, pdf);
592 break;
594 eval = bsdf_transparent_eval(sc, sd->wi, wo, pdf);
595 break;
597 eval = bsdf_ray_portal_eval(sc, sd->wi, wo, pdf);
598 break;
602 eval = bsdf_microfacet_ggx_eval(kg, sc, sd->wi, wo, pdf);
603 break;
605 eval = bsdf_thin_glass_transmission_eval(kg, sc, sd->wi, wo, pdf);
606 break;
610 eval = bsdf_microfacet_beckmann_eval(kg, sc, sd->wi, wo, pdf);
611 break;
613 eval = bsdf_ashikhmin_shirley_eval(sc, sd->wi, wo, pdf);
614 break;
616 eval = bsdf_ashikhmin_velvet_eval(sc, sd->wi, wo, pdf);
617 break;
619 eval = bsdf_diffuse_toon_eval(sc, sd->wi, wo, pdf);
620 break;
622 eval = bsdf_glossy_toon_eval(sc, sd->wi, wo, pdf);
623 break;
624# ifdef __PRINCIPLED_HAIR__
626 eval = bsdf_hair_chiang_eval(kg, sd, sc, wo, pdf);
627 break;
629 eval = bsdf_hair_huang_eval(kg, sd, sc, wo, pdf);
630 break;
631# endif
633 eval = bsdf_hair_reflection_eval(sc, sd->wi, wo, pdf);
634 break;
636 eval = bsdf_hair_transmission_eval(sc, sd->wi, wo, pdf);
637 break;
639 eval = bsdf_sheen_eval(sc, sd->wi, wo, pdf);
640 break;
641#endif
642 default:
643 break;
644 }
645
646 eval *= bump_shadowing;
647
648 /* Shadow terminator offset. */
649 const float frequency_multiplier =
650 kernel_data_fetch(objects, sd->object).shadow_terminator_shading_offset;
651 if (frequency_multiplier > 1.0f) {
652 const float cosNO = dot(wo, sc->N);
653 if (cosNO >= 0.0f) {
654 eval *= shift_cos_in(cosNO, frequency_multiplier);
655 }
656 }
657
658#ifdef WITH_CYCLES_DEBUG
659 kernel_assert(*pdf >= 0.0f);
660 kernel_assert(eval.x >= 0.0f && eval.y >= 0.0f && eval.z >= 0.0f);
661#endif
662 return eval;
663}
664
665ccl_device void bsdf_blur(ccl_private ShaderClosure *sc, const float roughness)
666{
667 /* TODO: do we want to blur volume closures? */
668#if defined(__SVM__) || defined(__OSL__)
669 switch (sc->type) {
677 /* TODO: Recompute energy preservation after blur? */
678 bsdf_microfacet_blur(sc, roughness);
679 break;
681 bsdf_ashikhmin_shirley_blur(sc, roughness);
682 break;
683# ifdef __PRINCIPLED_HAIR__
685 bsdf_hair_chiang_blur(sc, roughness);
686 break;
688 bsdf_hair_huang_blur(sc, roughness);
689 break;
690# endif
691 default:
692 break;
693 }
694#endif
695}
696
698 const ccl_private ShaderData *sd,
699 const ccl_private ShaderClosure *sc,
700 const bool reflection,
701 const bool transmission)
702{
703 Spectrum albedo = one_spectrum();
704 /* Some closures include additional components such as Fresnel terms that cause their albedo to
705 * be below 1. The point of this function is to return a best-effort estimation of their albedo,
706 * meaning the amount of reflected/refracted light that would be expected when illuminated by a
707 * uniform white background.
708 * This is used for the denoising albedo pass and diffuse/glossy/transmission color passes.
709 * NOTE: This should always match the sample_weight of the closure - as in, if there's an albedo
710 * adjustment in here, the sample_weight should also be reduced accordingly.
711 * TODO(lukas): Consider calling this function to determine the sample_weight? Would be a bit of
712 * extra overhead though. */
713#if defined(__SVM__) || defined(__OSL__)
714 if (CLOSURE_IS_BSDF_MICROFACET(sc->type)) {
716 kg, sd->wi, (const ccl_private MicrofacetBsdf *)sc, reflection, transmission);
717 }
718# ifdef __PRINCIPLED_HAIR__
719 else if (sc->type == CLOSURE_BSDF_HAIR_CHIANG_ID) {
720 /* TODO(lukas): Principled Hair could also be split into a glossy and a transmission component,
721 * similar to Glass BSDFs. */
722 albedo = bsdf_hair_chiang_albedo(sd, sc);
723 }
724 else if (sc->type == CLOSURE_BSDF_HAIR_HUANG_ID) {
725 albedo = bsdf_hair_huang_albedo(sd, sc);
726 }
727# endif
728#endif
729 return albedo;
730}
731
733 const ccl_private ShaderData *sd,
734 const ccl_private ShaderClosure *sc,
735 const bool reflection,
736 const bool transmission)
737{
738 return sc->weight * bsdf_albedo(kg, sd, sc, reflection, transmission);
739}
740
741/* Compute albedo used for layering this BSDF on top of another. The albedo is usually the
742 * reflection albedo. */
744 const ccl_private ShaderData *sd,
745 const ccl_private ShaderClosure *sc)
746{
747 /* Use `reduce_max()` to keep compatibility, need to check OSL and OpenPBR spec if we should
748 * remove tint for some closures. */
749 return sc->weight * reduce_max(bsdf_albedo(kg, sd, sc, true, false));
750}
751
ccl_device_forceinline float bsdf_widen_dD(const KernelGlobals kg, const float prev_dD, const float avg_roughness_squared)
Definition bsdf.h:77
ccl_device_inline Spectrum closure_layer_albedo(KernelGlobals kg, const ccl_private ShaderData *sd, const ccl_private ShaderClosure *sc)
Definition bsdf.h:743
CCL_NAMESPACE_BEGIN ccl_device_inline float bsdf_get_specular_roughness_squared(const ccl_private ShaderClosure *sc)
Definition bsdf.h:29
ccl_device Spectrum bsdf_eval(KernelGlobals kg, ccl_private ShaderData *sd, const ccl_private ShaderClosure *sc, const float3 wo, ccl_private float *pdf)
Definition bsdf.h:554
ccl_device_inline float bump_shadowing_term(const ccl_private ShaderData *sd, const ccl_private ShaderClosure *sc, const float3 I, const bool is_eval)
Definition bsdf.h:94
ccl_device_inline void bsdf_roughness_eta(const ccl_private ShaderClosure *sc, const float3 wo, ccl_private float2 *roughness, ccl_private float *eta)
Definition bsdf.h:333
ccl_device_inline float shift_cos_in(float cos_in, const float frequency_multiplier)
Definition bsdf.h:156
ccl_device_inline float bsdf_get_roughness_pass_squared(const ccl_private ShaderClosure *sc)
Definition bsdf.h:43
ccl_device_inline int bsdf_label(const KernelGlobals kg, const ccl_private ShaderClosure *sc, const float3 wo)
Definition bsdf.h:442
ccl_device_inline int bsdf_sample(KernelGlobals kg, ccl_private ShaderData *sd, const ccl_private ShaderClosure *sc, const float3 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf, ccl_private float2 *sampled_roughness, ccl_private float *eta)
Definition bsdf.h:173
ccl_device_inline Spectrum closure_albedo(KernelGlobals kg, const ccl_private ShaderData *sd, const ccl_private ShaderClosure *sc, const bool reflection, const bool transmission)
Definition bsdf.h:732
ccl_device_inline bool bsdf_is_transmission(const ccl_private ShaderClosure *sc, const float3 wo)
Definition bsdf.h:168
ccl_device_inline Spectrum bsdf_albedo(KernelGlobals kg, const ccl_private ShaderData *sd, const ccl_private ShaderClosure *sc, const bool reflection, const bool transmission)
Definition bsdf.h:697
ccl_device void bsdf_blur(ccl_private ShaderClosure *sc, const float roughness)
Definition bsdf.h:665
ccl_device void bsdf_ashikhmin_shirley_blur(ccl_private ShaderClosure *sc, const float roughness)
ccl_device_forceinline Spectrum bsdf_ashikhmin_shirley_eval(const ccl_private ShaderClosure *sc, const float3 wi, const float3 wo, ccl_private float *pdf)
ccl_device int bsdf_ashikhmin_shirley_sample(const ccl_private ShaderClosure *sc, const float3 Ng, const 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_ashikhmin_velvet_eval(const ccl_private ShaderClosure *sc, const float3 wi, const float3 wo, ccl_private float *pdf)
ccl_device int bsdf_ashikhmin_velvet_sample(const ccl_private ShaderClosure *sc, const float3 Ng, const float3 wi, const float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf)
ccl_device Spectrum bsdf_diffuse_eval(const ccl_private ShaderClosure *sc, const float3, const float3 wo, ccl_private float *pdf)
ccl_device Spectrum bsdf_translucent_eval(const ccl_private ShaderClosure *sc, const float3, const float3 wo, ccl_private float *pdf)
ccl_device int bsdf_diffuse_sample(const ccl_private ShaderClosure *sc, const float3 Ng, const float3, const float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf)
ccl_device int bsdf_translucent_sample(const ccl_private ShaderClosure *sc, const float3 Ng, const float3, const float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf)
ccl_device Spectrum bsdf_hair_reflection_eval(const ccl_private ShaderClosure *sc, const float3 wi, const float3 wo, ccl_private float *pdf)
Definition bsdf_hair.h:43
ccl_device int bsdf_hair_reflection_sample(const ccl_private ShaderClosure *sc, const float3, const float3 wi, const float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf, ccl_private float2 *sampled_roughness)
Definition bsdf_hair.h:146
ccl_device Spectrum bsdf_hair_transmission_eval(const ccl_private ShaderClosure *sc, const float3 wi, const float3 wo, ccl_private float *pdf)
Definition bsdf_hair.h:95
ccl_device int bsdf_hair_transmission_sample(const ccl_private ShaderClosure *sc, const float3, const float3 wi, const float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf, ccl_private float2 *sampled_roughness)
Definition bsdf_hair.h:201
ccl_device Spectrum bsdf_microfacet_ggx_eval(KernelGlobals kg, const ccl_private ShaderClosure *sc, const float3 wi, const float3 wo, ccl_private float *pdf)
ccl_device_forceinline int bsdf_microfacet_eval_flag(const ccl_private MicrofacetBsdf *bsdf)
ccl_device int bsdf_microfacet_beckmann_sample(KernelGlobals kg, const ccl_private ShaderClosure *sc, const float3 Ng, const float3 wi, const float3 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf, ccl_private float2 *sampled_roughness, ccl_private float *eta)
ccl_device Spectrum bsdf_thin_glass_transmission_eval(KernelGlobals kg, const ccl_private ShaderClosure *sc, const float3 wi, const float3 wo, ccl_private float *pdf)
ccl_device Spectrum bsdf_microfacet_estimate_albedo(KernelGlobals kg, const float3 wi, const ccl_private MicrofacetBsdf *bsdf, const bool eval_reflection, const bool eval_transmission)
ccl_device Spectrum bsdf_microfacet_beckmann_eval(KernelGlobals kg, const ccl_private ShaderClosure *sc, const float3 wi, const float3 wo, ccl_private float *pdf)
ccl_device int bsdf_thin_glass_transmission_sample(KernelGlobals kg, const ccl_private ShaderClosure *sc, const float3 Ng, const float3 wi, const float3 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf, ccl_private float2 *sampled_roughness, ccl_private float *eta)
ccl_device_inline float bsdf_G(const float alpha2, const float cos_N)
ccl_device int bsdf_microfacet_ggx_sample(KernelGlobals kg, const ccl_private ShaderClosure *sc, const float3 Ng, const float3 wi, const float3 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf, ccl_private float2 *sampled_roughness, ccl_private float *eta)
ccl_device void bsdf_microfacet_blur(ccl_private ShaderClosure *sc, const float roughness)
ccl_device int bsdf_oren_nayar_sample(const ccl_private ShaderClosure *sc, const float3 Ng, const float3 wi, const float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf, ccl_private float2 *sampled_roughness, ccl_private float *eta)
ccl_device int bsdf_rough_translucent_sample(const ccl_private ShaderClosure *sc, const float3 Ng, const float3 wi, const float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf, ccl_private float2 *sampled_roughness, ccl_private float *eta)
ccl_device Spectrum bsdf_oren_nayar_eval(const ccl_private ShaderClosure *sc, const float3 wi, const float3 wo, ccl_private float *pdf)
ccl_device Spectrum bsdf_rough_translucent_eval(const ccl_private ShaderClosure *sc, const float3 wi, const float3 wo, ccl_private float *pdf)
ccl_device int bsdf_hair_chiang_sample(KernelGlobals kg, const ccl_private ShaderClosure *sc, ccl_private ShaderData *sd, float3 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf, ccl_private float2 *sampled_roughness)
ccl_device Spectrum bsdf_hair_chiang_eval(KernelGlobals kg, const ccl_private ShaderData *sd, const ccl_private ShaderClosure *sc, const float3 wo, ccl_private float *pdf)
ccl_device void bsdf_hair_chiang_blur(ccl_private ShaderClosure *sc, const float roughness)
ccl_device Spectrum bsdf_hair_chiang_albedo(const ccl_private ShaderData *sd, const ccl_private ShaderClosure *sc)
ccl_device Spectrum bsdf_hair_huang_albedo(const ccl_private ShaderData *, const ccl_private ShaderClosure *sc)
ccl_device void bsdf_hair_huang_blur(ccl_private ShaderClosure *sc, const float roughness)
ccl_device int bsdf_hair_huang_sample(const KernelGlobals kg, const ccl_private ShaderClosure *sc, ccl_private ShaderData *sd, const float3 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf, ccl_private float2 *sampled_roughness)
ccl_device Spectrum bsdf_hair_huang_eval(KernelGlobals kg, ccl_private ShaderData *sd, const ccl_private ShaderClosure *sc, const float3 wo, ccl_private float *pdf)
ccl_device Spectrum bsdf_ray_portal_eval(const ccl_private ShaderClosure *, const float3, const float3, ccl_private float *pdf)
ccl_device int bsdf_sheen_sample(const ccl_private ShaderClosure *sc, const float3 Ng, const float3, const float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf)
Definition bsdf_sheen.h:107
ccl_device Spectrum bsdf_sheen_eval(const ccl_private ShaderClosure *sc, const float3, const float3 wo, ccl_private float *pdf)
Definition bsdf_sheen.h:86
ccl_device Spectrum bsdf_glossy_toon_eval(const ccl_private ShaderClosure *sc, const float3 wi, const float3 wo, ccl_private float *pdf)
Definition bsdf_toon.h:125
ccl_device int bsdf_diffuse_toon_sample(const ccl_private ShaderClosure *sc, const float3 Ng, const float3, const float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf)
Definition bsdf_toon.h:90
ccl_device int bsdf_glossy_toon_sample(const ccl_private ShaderClosure *sc, const float3 Ng, const float3 wi, const float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf)
Definition bsdf_toon.h:154
ccl_device Spectrum bsdf_diffuse_toon_eval(const ccl_private ShaderClosure *sc, const float3, const float3 wo, ccl_private float *pdf)
Definition bsdf_toon.h:65
ccl_device int bsdf_transparent_sample(const ccl_private ShaderClosure *, const float3, const float3 wi, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf)
ccl_device Spectrum bsdf_transparent_eval(const ccl_private ShaderClosure *, const float3, const float3, ccl_private float *pdf)
btScalar max
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition btVector3.h:356
#define kernel_assert(cond)
#define kernel_data
#define ccl_device_forceinline
#define CLOSURE_IS_BSDF_MICROFACET(type)
#define kernel_data_fetch(name, index)
#define one_spectrum
#define CLOSURE_IS_BSDF_SINGULAR(type)
#define zero_spectrum
#define ccl_private
#define ccl_device_inline
#define CLOSURE_IS_BSDF_DIFFUSE(type)
#define CCL_NAMESPACE_END
#define saturatef(x)
float dot(VecOp< float, D >, VecOp< float, D >) RET
float3x3 scale(float3x3 mat, float2 scale)
float reduce_max(float2 a)
@ CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID
@ CLOSURE_BSDF_PHONG_RAMP_ID
@ CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID
@ CLOSURE_BSDF_DIFFUSE_RAMP_ID
@ CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID
@ CLOSURE_BSDF_DIFFUSE_ID
@ CLOSURE_BSSRDF_BURLEY_ID
@ CLOSURE_BSDF_SHEEN_ID
@ CLOSURE_BSDF_TRANSPARENT_ID
@ CLOSURE_BSDF_DIFFUSE_TOON_ID
@ CLOSURE_BSDF_MICROFACET_GGX_ID
@ CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID
@ CLOSURE_BSDF_HAIR_TRANSMISSION_ID
@ CLOSURE_BSDF_BURLEY_ID
@ CLOSURE_BSDF_MICROFACET_BECKMANN_GLASS_ID
@ CLOSURE_BSSRDF_RANDOM_WALK_ID
@ CLOSURE_BSDF_HAIR_HUANG_ID
@ CLOSURE_BSDF_THIN_GLASS_TRANSMISSION_ID
@ CLOSURE_BSDF_MICROFACET_BECKMANN_ID
@ CLOSURE_BSSRDF_RANDOM_WALK_LEGACY_ID
@ CLOSURE_BSDF_RAY_PORTAL_ID
@ CLOSURE_BSDF_ROUGH_TRANSLUCENT_ID
@ CLOSURE_BSDF_OREN_NAYAR_ID
@ CLOSURE_BSDF_GLOSSY_TOON_ID
@ CLOSURE_BSDF_HAIR_CHIANG_ID
@ CLOSURE_BSDF_HAIR_REFLECTION_ID
@ CLOSURE_BSSRDF_RANDOM_WALK_SKIN_ID
@ CLOSURE_BSDF_TRANSLUCENT_ID
@ CLOSURE_BSDF_ASHIKHMIN_VELVET_ID
@ SD_USE_BUMP_MAP_CORRECTION
@ PRIMITIVE_CURVE
@ LABEL_TRANSMIT
@ LABEL_RAY_PORTAL
@ LABEL_TRANSMIT_TRANSPARENT
@ LABEL_DIFFUSE
@ LABEL_NONE
@ LABEL_SINGULAR
@ LABEL_GLOSSY
@ LABEL_REFLECT
@ LABEL_TRANSPARENT
ccl_device float fast_acosf(const float x)
Definition math_fast.h:259
ccl_device_inline float2 one_float2()
Definition math_float2.h:18
CCL_NAMESPACE_BEGIN ccl_device_inline float2 zero_float2()
Definition math_float2.h:13
ccl_device_inline bool isequal(const float2 a, const float2 b)
#define I
#define sqr
#define fabsf
#define sqrtf
#define ccl_device
#define make_float2
#define cosf
#define min(a, b)
Definition sort.cc:38
float3 Spectrum