Blender V4.3
closures_setup.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
11#include "kernel/closure/bsdf.h"
13
14#include "kernel/geom/object.h"
15
17
18#define OSL_CLOSURE_STRUCT_BEGIN(Upper, lower) \
19 struct ccl_align(8) Upper##Closure \
20 { \
21 const char *label;
22#define OSL_CLOSURE_STRUCT_END(Upper, lower) \
23 } \
24 ;
25#define OSL_CLOSURE_STRUCT_MEMBER(Upper, TYPE, type, name, key) type name;
26#define OSL_CLOSURE_STRUCT_ARRAY_MEMBER(Upper, TYPE, type, name, key, size) type name[size];
27
28#include "closures_template.h"
29
30struct ccl_align(8) LayerClosure
31{
32 ccl_private const OSLClosure *base;
34};
35
36/* If we failed to allocate a layer-able closure, we need to zero out the albedo
37 * so that lower layers aren't falsely blocked.
38 * Therefore, to keep the code clean, set it to zero at the start and overwrite
39 * later if it succeeded. */
41{
42 if (layer_albedo != NULL) {
43 *layer_albedo = zero_float3();
44 }
45}
46
48 ccl_private const ShaderData *sd,
49 uint32_t path_flag,
50 int scattering)
51{
52 /* Caustic options */
53 if ((scattering & LABEL_GLOSSY) && (path_flag & PATH_RAY_DIFFUSE)) {
54 const bool has_reflect = (scattering & LABEL_REFLECT);
55 const bool has_transmit = (scattering & LABEL_TRANSMIT);
56 const bool reflect_caustics_disabled = !kernel_data.integrator.caustics_reflective;
57 const bool refract_caustics_disabled = !kernel_data.integrator.caustics_refractive;
58
59 /* Reflective Caustics */
60 if (reflect_caustics_disabled && has_reflect && !has_transmit) {
61 return true;
62 }
63 /* Refractive Caustics */
64 if (refract_caustics_disabled && has_transmit && !has_reflect) {
65 return true;
66 }
67 /* Glass Caustics */
68 if (reflect_caustics_disabled && refract_caustics_disabled) {
69 return true;
70 }
71 }
72
73 return false;
74}
75
76/* Diffuse */
77
80 uint32_t path_flag,
81 float3 weight,
82 ccl_private const DiffuseClosure *closure,
83 float3 *layer_albedo)
84{
85 if (osl_closure_skip(kg, sd, path_flag, LABEL_DIFFUSE)) {
86 return;
87 }
88
90 sd, sizeof(DiffuseBsdf), rgb_to_spectrum(weight));
91 if (!bsdf) {
92 return;
93 }
94
95 bsdf->N = safe_normalize_fallback(closure->N, sd->N);
96
97 sd->flag |= bsdf_diffuse_setup(bsdf);
98}
99
100/* Deprecated form, will be removed in OSL 2.0. */
103 uint32_t path_flag,
104 float3 weight,
105 ccl_private const OrenNayarClosure *closure,
106 float3 *layer_albedo)
107{
108 if (osl_closure_skip(kg, sd, path_flag, LABEL_DIFFUSE)) {
109 return;
110 }
111
113 sd, sizeof(OrenNayarBsdf), rgb_to_spectrum(weight));
114 if (!bsdf) {
115 return;
116 }
117
118 bsdf->N = safe_normalize_fallback(closure->N, sd->N);
119 bsdf->roughness = closure->roughness;
120
121 sd->flag |= bsdf_oren_nayar_setup(sd, bsdf, rgb_to_spectrum(weight));
122}
123
125 KernelGlobals kg,
127 uint32_t path_flag,
128 float3 weight,
129 ccl_private const OrenNayarDiffuseBSDFClosure *closure,
130 float3 *layer_albedo)
131{
132 if (osl_closure_skip(kg, sd, path_flag, LABEL_DIFFUSE)) {
133 return;
134 }
135
137 sd, sizeof(OrenNayarBsdf), rgb_to_spectrum(weight));
138 if (!bsdf) {
139 return;
140 }
141
142 bsdf->N = safe_normalize_fallback(closure->N, sd->N);
143 bsdf->roughness = closure->roughness;
144
145 sd->flag |= bsdf_oren_nayar_setup(sd, bsdf, rgb_to_spectrum(closure->albedo));
146}
147
150 uint32_t path_flag,
151 float3 weight,
152 ccl_private const TranslucentClosure *closure,
153 float3 *layer_albedo)
154{
155 if (osl_closure_skip(kg, sd, path_flag, LABEL_DIFFUSE)) {
156 return;
157 }
158
160 sd, sizeof(DiffuseBsdf), rgb_to_spectrum(weight));
161 if (!bsdf) {
162 return;
163 }
164
165 bsdf->N = safe_normalize_fallback(closure->N, sd->N);
166
167 sd->flag |= bsdf_translucent_setup(bsdf);
168}
169
172 uint32_t path_flag,
173 float3 weight,
174 ccl_private const ReflectionClosure *closure,
175 float3 *layer_albedo)
176{
177 if (osl_closure_skip(kg, sd, path_flag, LABEL_SINGULAR)) {
178 return;
179 }
180
182 sd, sizeof(MicrofacetBsdf), rgb_to_spectrum(weight));
183 if (!bsdf) {
184 return;
185 }
186
187 bsdf->N = maybe_ensure_valid_specular_reflection(sd, safe_normalize_fallback(closure->N, sd->N));
188 bsdf->alpha_x = bsdf->alpha_y = 0.0f;
189
190 sd->flag |= bsdf_microfacet_ggx_setup(bsdf);
191}
192
195 uint32_t path_flag,
196 float3 weight,
197 ccl_private const RefractionClosure *closure,
198 float3 *layer_albedo)
199{
200 if (osl_closure_skip(kg, sd, path_flag, LABEL_SINGULAR)) {
201 return;
202 }
203
205 sd, sizeof(MicrofacetBsdf), rgb_to_spectrum(weight));
206 if (!bsdf) {
207 return;
208 }
209
210 bsdf->N = maybe_ensure_valid_specular_reflection(sd, safe_normalize_fallback(closure->N, sd->N));
211 bsdf->ior = closure->ior;
212 bsdf->alpha_x = bsdf->alpha_y = 0.0f;
213
214 sd->flag |= bsdf_microfacet_ggx_refraction_setup(bsdf);
215}
216
219 uint32_t path_flag,
220 float3 weight,
221 ccl_private const TransparentClosure *closure,
222 float3 *layer_albedo)
223{
224 bsdf_transparent_setup(sd, rgb_to_spectrum(weight), path_flag);
225}
226
229 uint32_t path_flag,
230 float3 weight,
231 ccl_private const RayPortalBSDFClosure *closure,
232 float3 *layer_albedo)
233{
235 sd, rgb_to_spectrum(weight), path_flag, closure->position, closure->direction);
236}
237
238/* MaterialX closures */
241 uint32_t path_flag,
242 float3 weight,
243 ccl_private const DielectricBSDFClosure *closure,
244 float3 *layer_albedo)
245{
246 osl_zero_albedo(layer_albedo);
247
248 const bool has_reflection = !is_zero(closure->reflection_tint);
249 const bool has_transmission = !is_zero(closure->transmission_tint);
250
251 if (osl_closure_skip(kg, sd, path_flag, LABEL_GLOSSY | LABEL_REFLECT)) {
252 return;
253 }
254
256 sd, sizeof(MicrofacetBsdf), rgb_to_spectrum(weight));
257 if (!bsdf) {
258 return;
259 }
260
263 if (!fresnel) {
264 return;
265 }
266
267 bsdf->N = maybe_ensure_valid_specular_reflection(sd, safe_normalize_fallback(closure->N, sd->N));
268 bsdf->alpha_x = closure->alpha_x;
269 bsdf->alpha_y = closure->alpha_y;
270 bsdf->ior = closure->ior;
271 bsdf->T = closure->T;
272
273 bool preserve_energy = false;
274
275 /* Beckmann */
276 if (closure->distribution == make_string("beckmann", 14712237670914973463ull)) {
277 if (has_reflection && has_transmission) {
278 sd->flag |= bsdf_microfacet_beckmann_glass_setup(bsdf);
279 }
280 else if (has_transmission) {
282 }
283 else {
284 sd->flag |= bsdf_microfacet_beckmann_setup(bsdf);
285 }
286 }
287 /* GGX (either single- or multi-scattering). */
288 else {
289 if (has_reflection && has_transmission) {
290 sd->flag |= bsdf_microfacet_ggx_glass_setup(bsdf);
291 }
292 else if (has_transmission) {
293 sd->flag |= bsdf_microfacet_ggx_refraction_setup(bsdf);
294 }
295 else {
296 sd->flag |= bsdf_microfacet_ggx_setup(bsdf);
297 }
298
299 preserve_energy = (closure->distribution == make_string("multi_ggx", 16842698693386468366ull));
300 }
301
302 fresnel->reflection_tint = rgb_to_spectrum(closure->reflection_tint);
303 fresnel->transmission_tint = rgb_to_spectrum(closure->transmission_tint);
304 fresnel->thin_film.thickness = closure->thinfilm_thickness;
305 fresnel->thin_film.ior = closure->thinfilm_ior;
306 bsdf_microfacet_setup_fresnel_dielectric_tint(kg, bsdf, sd, fresnel, preserve_energy);
307
308 if (layer_albedo != NULL) {
309 if (has_reflection && !has_transmission) {
310 *layer_albedo = bsdf_albedo(kg, sd, (ccl_private ShaderClosure *)bsdf, true, false);
311 }
312 else {
313 *layer_albedo = one_float3();
314 }
315 }
316}
317
320 uint32_t path_flag,
321 float3 weight,
322 ccl_private const ConductorBSDFClosure *closure,
323 float3 *layer_albedo)
324{
325 if (osl_closure_skip(kg, sd, path_flag, LABEL_GLOSSY | LABEL_REFLECT)) {
326 return;
327 }
328
330 sd, sizeof(MicrofacetBsdf), rgb_to_spectrum(weight));
331 if (!bsdf) {
332 return;
333 }
334
336 sd, sizeof(FresnelConductor));
337 if (!fresnel) {
338 return;
339 }
340
341 bsdf->N = maybe_ensure_valid_specular_reflection(sd, safe_normalize_fallback(closure->N, sd->N));
342 bsdf->alpha_x = closure->alpha_x;
343 bsdf->alpha_y = closure->alpha_y;
344 bsdf->ior = 0.0f;
345 bsdf->T = closure->T;
346
347 bool preserve_energy = false;
348
349 /* Beckmann */
350 if (closure->distribution == make_string("beckmann", 14712237670914973463ull)) {
351 sd->flag |= bsdf_microfacet_beckmann_setup(bsdf);
352 }
353 /* GGX (either single- or multi-scattering) */
354 else {
355 sd->flag |= bsdf_microfacet_ggx_setup(bsdf);
356 preserve_energy = (closure->distribution == make_string("multi_ggx", 16842698693386468366ull));
357 }
358
359 fresnel->n = rgb_to_spectrum(closure->ior);
360 fresnel->k = rgb_to_spectrum(closure->extinction);
361 bsdf_microfacet_setup_fresnel_conductor(kg, bsdf, sd, fresnel, preserve_energy);
362}
363
365 KernelGlobals kg,
367 uint32_t path_flag,
368 float3 weight,
369 ccl_private const GeneralizedSchlickBSDFClosure *closure,
370 float3 *layer_albedo)
371{
372 osl_zero_albedo(layer_albedo);
373
374 const bool has_reflection = !is_zero(closure->reflection_tint);
375 const bool has_transmission = !is_zero(closure->transmission_tint);
376
378 if (has_transmission) {
380 }
381
382 if (osl_closure_skip(kg, sd, path_flag, label)) {
383 return;
384 }
385
387 sd, sizeof(MicrofacetBsdf), rgb_to_spectrum(weight));
388 if (!bsdf) {
389 return;
390 }
391
394 if (!fresnel) {
395 return;
396 }
397
398 bsdf->N = maybe_ensure_valid_specular_reflection(sd, safe_normalize_fallback(closure->N, sd->N));
399 bsdf->alpha_x = closure->alpha_x;
400 bsdf->alpha_y = closure->alpha_y;
401 bsdf->T = closure->T;
402
403 if (closure->exponent < 0.0f) {
404 /* Trick for principled BSDF: Since we use the real Fresnel equation and remap
405 * to the F0...F90 range, this allows us to use the real IOR.
406 * Computing it back from F0 might give a different result in case of specular
407 * tinting. */
408 bsdf->ior = -closure->exponent;
409 }
410 else {
411 bsdf->ior = ior_from_F0(average(closure->f0));
412 }
413
414 bool preserve_energy = false;
415
416 /* Beckmann */
417 if (closure->distribution == make_string("beckmann", 14712237670914973463ull)) {
418 if (has_reflection && has_transmission) {
419 sd->flag |= bsdf_microfacet_beckmann_glass_setup(bsdf);
420 }
421 else if (has_transmission) {
423 }
424 else {
425 sd->flag |= bsdf_microfacet_beckmann_setup(bsdf);
426 }
427 }
428 /* GGX (either single- or multi-scattering) */
429 else {
430 if (has_reflection && has_transmission) {
431 sd->flag |= bsdf_microfacet_ggx_glass_setup(bsdf);
432 }
433 else if (has_transmission) {
434 sd->flag |= bsdf_microfacet_ggx_refraction_setup(bsdf);
435 }
436 else {
437 sd->flag |= bsdf_microfacet_ggx_setup(bsdf);
438 }
439
440 preserve_energy = (closure->distribution == make_string("multi_ggx", 16842698693386468366ull));
441 }
442
443 const bool reflective_caustics = (kernel_data.integrator.caustics_reflective ||
444 (path_flag & PATH_RAY_DIFFUSE) == 0);
445 const bool refractive_caustics = (kernel_data.integrator.caustics_refractive ||
446 (path_flag & PATH_RAY_DIFFUSE) == 0);
447
448 fresnel->reflection_tint = reflective_caustics ? rgb_to_spectrum(closure->reflection_tint) :
450 fresnel->transmission_tint = refractive_caustics ? rgb_to_spectrum(closure->transmission_tint) :
452 fresnel->f0 = rgb_to_spectrum(closure->f0);
453 fresnel->f90 = rgb_to_spectrum(closure->f90);
454 fresnel->exponent = closure->exponent;
455 fresnel->thin_film.thickness = closure->thinfilm_thickness;
456 fresnel->thin_film.ior = closure->thinfilm_ior;
457 bsdf_microfacet_setup_fresnel_generalized_schlick(kg, bsdf, sd, fresnel, preserve_energy);
458
459 if (layer_albedo != NULL) {
460 if (has_reflection && !has_transmission) {
461 *layer_albedo = bsdf_albedo(kg, sd, (ccl_private ShaderClosure *)bsdf, true, false);
462 }
463 else {
464 *layer_albedo = one_float3();
465 }
466 }
467}
468
469/* Standard microfacet closures */
470
473 uint32_t path_flag,
474 float3 weight,
475 ccl_private const MicrofacetClosure *closure,
476 float3 *layer_albedo)
477{
478 osl_zero_albedo(layer_albedo);
479
480 const int label = (closure->refract) ? LABEL_TRANSMIT : LABEL_REFLECT;
481 if (osl_closure_skip(kg, sd, path_flag, LABEL_GLOSSY | label)) {
482 return;
483 }
484
486 sd, sizeof(MicrofacetBsdf), rgb_to_spectrum(weight));
487 if (!bsdf) {
488 return;
489 }
490
491 bsdf->N = maybe_ensure_valid_specular_reflection(sd, safe_normalize_fallback(closure->N, sd->N));
492 bsdf->alpha_x = closure->alpha_x;
493 bsdf->alpha_y = closure->alpha_y;
494 bsdf->ior = closure->ior;
495 bsdf->T = closure->T;
496
497 /* Beckmann */
498 if (closure->distribution == make_string("beckmann", 14712237670914973463ull)) {
499 if (closure->refract == 1) {
501 }
502 else if (closure->refract == 2) {
503 sd->flag |= bsdf_microfacet_beckmann_glass_setup(bsdf);
504 }
505 else {
506 sd->flag |= bsdf_microfacet_beckmann_setup(bsdf);
507 }
508 }
509 /* Ashikhmin-Shirley */
510 else if (closure->distribution == make_string("ashikhmin_shirley", 11318482998918370922ull)) {
511 sd->flag |= bsdf_ashikhmin_shirley_setup(bsdf);
512 }
513 /* GGX (either single- or multi-scattering) */
514 else {
515 if (closure->refract == 1) {
516 sd->flag |= bsdf_microfacet_ggx_refraction_setup(bsdf);
517 }
518 else if (closure->refract == 2) {
519 sd->flag |= bsdf_microfacet_ggx_glass_setup(bsdf);
520 }
521 else {
522 sd->flag |= bsdf_microfacet_ggx_setup(bsdf);
523 }
524
525 if (closure->distribution == make_string("multi_ggx", 16842698693386468366ull)) {
526 /* Since there's no dedicated color input, the weight is the best we got. */
528 }
529 }
530
531 if (layer_albedo != NULL) {
532 if (closure->refract == 0) {
533 *layer_albedo = bsdf_albedo(kg, sd, (ccl_private ShaderClosure *)bsdf, true, false);
534 }
535 else {
536 *layer_albedo = one_float3();
537 }
538 }
539}
540
541/* Special-purpose Microfacet closures */
542
544 KernelGlobals kg,
546 uint32_t path_flag,
547 float3 weight,
548 ccl_private const MicrofacetF82TintClosure *closure,
549 float3 *layer_albedo)
550{
551 if (osl_closure_skip(kg, sd, path_flag, LABEL_GLOSSY | LABEL_REFLECT)) {
552 return;
553 }
554
556 sd, sizeof(MicrofacetBsdf), rgb_to_spectrum(weight));
557 if (!bsdf) {
558 return;
559 }
560
562 sd, sizeof(FresnelF82Tint));
563 if (!fresnel) {
564 return;
565 }
566
567 bsdf->N = maybe_ensure_valid_specular_reflection(sd, safe_normalize_fallback(closure->N, sd->N));
568 bsdf->alpha_x = closure->alpha_x;
569 bsdf->alpha_y = closure->alpha_y;
570 bsdf->ior = 0.0f;
571 bsdf->T = closure->T;
572
573 bool preserve_energy = false;
574
575 /* Beckmann */
576 if (closure->distribution == make_string("beckmann", 14712237670914973463ull)) {
577 sd->flag |= bsdf_microfacet_beckmann_setup(bsdf);
578 }
579 /* GGX (either single- or multi-scattering) */
580 else {
581 sd->flag |= bsdf_microfacet_ggx_setup(bsdf);
582 preserve_energy = (closure->distribution == make_string("multi_ggx", 16842698693386468366ull));
583 }
584
585 fresnel->f0 = rgb_to_spectrum(closure->f0);
587 kg, bsdf, sd, fresnel, rgb_to_spectrum(closure->f82), preserve_energy);
588}
589
591 KernelGlobals kg,
593 uint32_t path_flag,
594 float3 weight,
595 ccl_private const MicrofacetMultiGGXGlassClosure *closure,
596 float3 *layer_albedo)
597{
598 /* Technically, the MultiGGX closure may also transmit. However,
599 * since this is set statically and only used for caustic flags, this
600 * is probably as good as it gets. */
601 if (osl_closure_skip(kg, sd, path_flag, LABEL_GLOSSY | LABEL_REFLECT)) {
602 return;
603 }
604
606 sd, sizeof(MicrofacetBsdf), rgb_to_spectrum(weight));
607 if (!bsdf) {
608 return;
609 }
610
611 bsdf->N = maybe_ensure_valid_specular_reflection(sd, safe_normalize_fallback(closure->N, sd->N));
612 bsdf->alpha_x = closure->alpha_x;
613 bsdf->alpha_y = bsdf->alpha_x;
614 bsdf->ior = closure->ior;
615
616 bsdf->T = zero_float3();
617
618 sd->flag |= bsdf_microfacet_ggx_glass_setup(bsdf);
619 bsdf_microfacet_setup_fresnel_constant(kg, bsdf, sd, rgb_to_spectrum(closure->color));
620}
621
623 KernelGlobals kg,
625 uint32_t path_flag,
626 float3 weight,
627 ccl_private const MicrofacetMultiGGXClosure *closure,
628 float3 *layer_albedo)
629{
630 osl_zero_albedo(layer_albedo);
631
632 if (osl_closure_skip(kg, sd, path_flag, LABEL_GLOSSY | LABEL_REFLECT)) {
633 return;
634 }
635
637 sd, sizeof(MicrofacetBsdf), rgb_to_spectrum(weight));
638 if (!bsdf) {
639 return;
640 }
641
642 bsdf->N = maybe_ensure_valid_specular_reflection(sd, safe_normalize_fallback(closure->N, sd->N));
643 bsdf->alpha_x = closure->alpha_x;
644 bsdf->alpha_y = closure->alpha_y;
645 bsdf->ior = 1.0f;
646
647 bsdf->T = closure->T;
648
649 sd->flag |= bsdf_microfacet_ggx_setup(bsdf);
650 bsdf_microfacet_setup_fresnel_constant(kg, bsdf, sd, rgb_to_spectrum(closure->color));
651
652 if (layer_albedo != NULL) {
653 *layer_albedo = bsdf_albedo(kg, sd, (ccl_private ShaderClosure *)bsdf, true, false);
654 }
655}
656
657/* Ashikhmin Velvet */
658
660 KernelGlobals kg,
662 uint32_t path_flag,
663 float3 weight,
664 ccl_private const AshikhminVelvetClosure *closure,
665 float3 *layer_albedo)
666{
667 if (osl_closure_skip(kg, sd, path_flag, LABEL_DIFFUSE)) {
668 return;
669 }
670
672 sd, sizeof(VelvetBsdf), rgb_to_spectrum(weight));
673 if (!bsdf) {
674 return;
675 }
676
677 bsdf->N = maybe_ensure_valid_specular_reflection(sd, safe_normalize_fallback(closure->N, sd->N));
678 bsdf->sigma = closure->sigma;
679
680 sd->flag |= bsdf_ashikhmin_velvet_setup(bsdf);
681}
682
683/* Sheen */
684
687 uint32_t path_flag,
688 float3 weight,
689 ccl_private const SheenClosure *closure,
690 float3 *layer_albedo)
691{
692 osl_zero_albedo(layer_albedo);
693
694 if (osl_closure_skip(kg, sd, path_flag, LABEL_DIFFUSE)) {
695 return;
696 }
697
699 sd, sizeof(SheenBsdf), rgb_to_spectrum(weight));
700 if (!bsdf) {
701 return;
702 }
703
704 bsdf->N = safe_normalize_fallback(closure->N, sd->N);
705 bsdf->roughness = closure->roughness;
706
707 const int sheen_flag = bsdf_sheen_setup(kg, sd, bsdf);
708
709 if (sheen_flag) {
710 sd->flag |= sheen_flag;
711
712 if (layer_albedo != NULL) {
713 *layer_albedo = bsdf->weight;
714 }
715 }
716}
717
720 uint32_t path_flag,
721 float3 weight,
722 ccl_private const DiffuseToonClosure *closure,
723 float3 *layer_albedo)
724{
725 if (osl_closure_skip(kg, sd, path_flag, LABEL_DIFFUSE)) {
726 return;
727 }
728
730 sd, sizeof(ToonBsdf), rgb_to_spectrum(weight));
731 if (!bsdf) {
732 return;
733 }
734
735 bsdf->N = maybe_ensure_valid_specular_reflection(sd, safe_normalize_fallback(closure->N, sd->N));
736 bsdf->size = closure->size;
737 bsdf->smooth = closure->smooth;
738
739 sd->flag |= bsdf_diffuse_toon_setup(bsdf);
740}
741
744 uint32_t path_flag,
745 float3 weight,
746 ccl_private const GlossyToonClosure *closure,
747 float3 *layer_albedo)
748{
749 if (osl_closure_skip(kg, sd, path_flag, LABEL_GLOSSY)) {
750 return;
751 }
752
754 sd, sizeof(ToonBsdf), rgb_to_spectrum(weight));
755 if (!bsdf) {
756 return;
757 }
758
759 bsdf->N = maybe_ensure_valid_specular_reflection(sd, safe_normalize_fallback(closure->N, sd->N));
760 bsdf->size = closure->size;
761 bsdf->smooth = closure->smooth;
762
763 sd->flag |= bsdf_glossy_toon_setup(bsdf);
764}
765
766/* Variable cone emissive closure
767 *
768 * This primitive emits in a cone having a configurable penumbra area where the light decays to 0
769 * reaching the outer_angle limit. It can also behave as a lambertian emitter if the provided
770 * angles are PI/2, which is the default
771 */
774 uint32_t /*path_flag*/,
775 float3 weight,
776 ccl_private const GenericEmissiveClosure *closure,
777 float3 *layer_albedo)
778{
779 if (sd->flag & SD_IS_VOLUME_SHADER_EVAL) {
780 weight *= object_volume_density(kg, sd->object);
781 }
782 emission_setup(sd, rgb_to_spectrum(weight));
783}
784
785/* Generic background closure
786 *
787 * We only have a background closure for the shaders to return a color in background shaders. No
788 * methods, only the weight is taking into account
789 */
792 uint32_t /*path_flag*/,
793 float3 weight,
794 ccl_private const GenericBackgroundClosure *closure,
795 float3 *layer_albedo)
796{
798}
799
800/* Holdout closure
801 *
802 * This will be used by the shader to mark the amount of holdout for the current shading point. No
803 * parameters, only the weight will be used
804 */
807 uint32_t /*path_flag*/,
808 float3 weight,
809 ccl_private const HoldoutClosure *closure,
810 float3 *layer_albedo)
811{
813 sd->flag |= SD_HOLDOUT;
814}
815
818 uint32_t /*path_flag*/,
819 float3 weight,
820 ccl_private const DiffuseRampClosure *closure,
821 float3 *layer_albedo)
822{
823 ccl_private DiffuseRampBsdf *bsdf = (ccl_private DiffuseRampBsdf *)bsdf_alloc(
824 sd, sizeof(DiffuseRampBsdf), rgb_to_spectrum(weight));
825
826 if (!bsdf) {
827 return;
828 }
829
830 bsdf->N = safe_normalize_fallback(closure->N, sd->N);
831
832 bsdf->colors = (float3 *)closure_alloc_extra(sd, sizeof(float3) * 8);
833 if (!bsdf->colors) {
834 return;
835 }
836
837 for (int i = 0; i < 8; i++) {
838 bsdf->colors[i] = closure->colors[i];
839 }
840
841 sd->flag |= bsdf_diffuse_ramp_setup(bsdf);
842}
843
846 uint32_t /*path_flag*/,
847 float3 weight,
848 ccl_private const PhongRampClosure *closure,
849 float3 *layer_albedo)
850{
851 ccl_private PhongRampBsdf *bsdf = (ccl_private PhongRampBsdf *)bsdf_alloc(
852 sd, sizeof(PhongRampBsdf), rgb_to_spectrum(weight));
853 if (!bsdf) {
854 return;
855 }
856
857 bsdf->N = maybe_ensure_valid_specular_reflection(sd, safe_normalize_fallback(closure->N, sd->N));
858 bsdf->exponent = closure->exponent;
859
860 bsdf->colors = (float3 *)closure_alloc_extra(sd, sizeof(float3) * 8);
861 if (!bsdf->colors) {
862 return;
863 }
864
865 for (int i = 0; i < 8; i++) {
866 bsdf->colors[i] = closure->colors[i];
867 }
868
869 sd->flag |= bsdf_phong_ramp_setup(bsdf);
870}
871
874 uint32_t path_flag,
875 float3 weight,
876 ccl_private const BSSRDFClosure *closure,
877 float3 *layer_albedo)
878{
879 ClosureType type;
880 if (closure->method == make_string("burley", 186330084368958868ull)) {
882 }
883 else if (closure->method == make_string("random_walk", 11360609267673527222ull)) {
885 }
886 else if (closure->method == make_string("random_walk_skin", 3096325052680726300ull)) {
888 }
889 else {
890 return;
891 }
892
894 if (!bssrdf) {
895 return;
896 }
897
898 bssrdf->radius = closure->radius;
899
900 /* create one closure per color channel */
901 bssrdf->albedo = closure->albedo;
903 safe_normalize_fallback(closure->N, sd->N));
904 bssrdf->alpha = closure->roughness;
905 bssrdf->ior = closure->ior;
906 bssrdf->anisotropy = closure->anisotropy;
907
908 sd->flag |= bssrdf_setup(sd, bssrdf, path_flag, type);
909}
910
911/* Hair */
912
915 uint32_t path_flag,
916 float3 weight,
917 ccl_private const HairReflectionClosure *closure,
918 float3 *layer_albedo)
919{
920 if (osl_closure_skip(kg, sd, path_flag, LABEL_GLOSSY)) {
921 return;
922 }
923
925 sd, sizeof(HairBsdf), rgb_to_spectrum(weight));
926 if (!bsdf) {
927 return;
928 }
929
930 bsdf->N = maybe_ensure_valid_specular_reflection(sd, safe_normalize_fallback(closure->N, sd->N));
931 bsdf->T = closure->T;
932 bsdf->roughness1 = closure->roughness1;
933 bsdf->roughness2 = closure->roughness2;
934 bsdf->offset = closure->offset;
935
936 sd->flag |= bsdf_hair_reflection_setup(bsdf);
937}
938
940 KernelGlobals kg,
942 uint32_t path_flag,
943 float3 weight,
944 ccl_private const HairTransmissionClosure *closure,
945 float3 *layer_albedo)
946{
947 if (osl_closure_skip(kg, sd, path_flag, LABEL_GLOSSY)) {
948 return;
949 }
950
952 sd, sizeof(HairBsdf), rgb_to_spectrum(weight));
953 if (!bsdf) {
954 return;
955 }
956
957 bsdf->N = maybe_ensure_valid_specular_reflection(sd, safe_normalize_fallback(closure->N, sd->N));
958 bsdf->T = closure->T;
959 bsdf->roughness1 = closure->roughness1;
960 bsdf->roughness2 = closure->roughness2;
961 bsdf->offset = closure->offset;
962
963 sd->flag |= bsdf_hair_transmission_setup(bsdf);
964}
965
968 uint32_t path_flag,
969 float3 weight,
970 ccl_private const ChiangHairClosure *closure,
971 float3 *layer_albedo)
972{
973#ifdef __HAIR__
974 if (osl_closure_skip(kg, sd, path_flag, LABEL_GLOSSY)) {
975 return;
976 }
977
979 sd, sizeof(ChiangHairBSDF), rgb_to_spectrum(weight));
980 if (!bsdf) {
981 return;
982 }
983
984 bsdf->N = maybe_ensure_valid_specular_reflection(sd, safe_normalize_fallback(closure->N, sd->N));
985 bsdf->sigma = closure->sigma;
986 bsdf->v = closure->v;
987 bsdf->s = closure->s;
988 bsdf->alpha = closure->alpha;
989 bsdf->eta = closure->eta;
990 bsdf->m0_roughness = closure->m0_roughness;
991
992 sd->flag |= bsdf_hair_chiang_setup(sd, bsdf);
993#endif
994}
995
998 uint32_t path_flag,
999 float3 weight,
1000 ccl_private const HuangHairClosure *closure,
1001 float3 *layer_albedo)
1002{
1003#ifdef __HAIR__
1004 if (osl_closure_skip(kg, sd, path_flag, LABEL_GLOSSY)) {
1005 return;
1006 }
1007
1008 if (closure->r_lobe <= 0.0f && closure->tt_lobe <= 0.0f && closure->trt_lobe <= 0.0f) {
1009 return;
1010 }
1011
1013 sd, sizeof(HuangHairBSDF), rgb_to_spectrum(weight));
1014 if (!bsdf) {
1015 return;
1016 }
1017
1019 sd, sizeof(HuangHairExtra));
1020 if (!extra) {
1021 return;
1022 }
1023
1024 bsdf->N = safe_normalize_fallback(closure->N, sd->N);
1025 bsdf->sigma = closure->sigma;
1026 bsdf->roughness = closure->roughness;
1027 bsdf->tilt = closure->tilt;
1028 bsdf->eta = closure->eta;
1029 bsdf->aspect_ratio = closure->aspect_ratio;
1030
1031 bsdf->extra = extra;
1032 bsdf->extra->R = closure->r_lobe;
1033 bsdf->extra->TT = closure->tt_lobe;
1034 bsdf->extra->TRT = closure->trt_lobe;
1035
1036 bsdf->extra->pixel_coverage = 1.0f;
1037
1038 /* For camera ray, check if the hair covers more than one pixel, in which case a nearfield model
1039 * is needed to prevent ribbon-like appearance. */
1040 if ((path_flag & PATH_RAY_CAMERA) && (sd->type & PRIMITIVE_CURVE)) {
1041 /* Interpolate radius between curve keys. */
1042 const KernelCurve kcurve = kernel_data_fetch(curves, sd->prim);
1043 const int k0 = kcurve.first_key + PRIMITIVE_UNPACK_SEGMENT(sd->type);
1044 const int k1 = k0 + 1;
1045 const float radius = mix(
1046 kernel_data_fetch(curve_keys, k0).w, kernel_data_fetch(curve_keys, k1).w, sd->u);
1047
1048 bsdf->extra->pixel_coverage = 0.5f * sd->dP / radius;
1049 }
1050
1051 sd->flag |= bsdf_hair_huang_setup(sd, bsdf, path_flag);
1052#endif
1053}
1054
1055/* Volume */
1056
1059 uint32_t path_flag,
1060 float3 weight,
1061 ccl_private const VolumeAbsorptionClosure *closure,
1062 float3 *layer_albedo)
1063{
1064 volume_extinction_setup(sd, rgb_to_spectrum(weight * object_volume_density(kg, sd->object)));
1065}
1066
1068 KernelGlobals kg,
1070 uint32_t path_flag,
1071 float3 weight,
1072 ccl_private const VolumeHenyeyGreensteinClosure *closure,
1073 float3 *layer_albedo)
1074{
1075 weight *= object_volume_density(kg, sd->object);
1077
1079 sd, sizeof(HenyeyGreensteinVolume), rgb_to_spectrum(weight));
1080 if (!volume) {
1081 return;
1082 }
1083
1084 volume->g = closure->g;
1085
1086 sd->flag |= volume_henyey_greenstein_setup(volume);
1087}
1088
1090 KernelGlobals kg,
1092 uint32_t path_flag,
1093 float3 weight,
1094 ccl_private const VolumeFournierForandClosure *closure,
1095 float3 *layer_albedo)
1096{
1098
1100 sd, sizeof(FournierForandVolume), rgb_to_spectrum(weight));
1101 if (!volume) {
1102 return;
1103 }
1104
1105 sd->flag |= volume_fournier_forand_setup(volume, closure->B, closure->IOR);
1106}
1107
1110 uint32_t path_flag,
1111 float3 weight,
1112 ccl_private const VolumeDraineClosure *closure,
1113 float3 *layer_albedo)
1114{
1116
1118 sd, sizeof(DraineVolume), rgb_to_spectrum(weight));
1119 if (!volume) {
1120 return;
1121 }
1122
1123 volume->g = closure->g;
1124 volume->alpha = closure->alpha;
1125
1126 sd->flag |= volume_draine_setup(volume);
1127}
1128
1131 uint32_t path_flag,
1132 float3 weight,
1133 ccl_private const VolumeRayleighClosure *closure,
1134 float3 *layer_albedo)
1135{
1137
1139 sd, sizeof(RayleighVolume), rgb_to_spectrum(weight));
1140 if (!volume) {
1141 return;
1142 }
1143
1144 sd->flag |= volume_rayleigh_setup(volume);
1145}
1146
ccl_device_inline ccl_private ShaderClosure * bsdf_alloc(ccl_private ShaderData *sd, int size, Spectrum weight)
Definition alloc.h:52
ccl_device ccl_private void * closure_alloc_extra(ccl_private ShaderData *sd, int size)
Definition alloc.h:31
CCL_NAMESPACE_BEGIN ccl_device ccl_private ShaderClosure * closure_alloc(ccl_private ShaderData *sd, int size, ClosureType type, Spectrum weight)
Definition alloc.h:9
ccl_device_inline Spectrum bsdf_albedo(KernelGlobals kg, ccl_private const ShaderData *sd, ccl_private const ShaderClosure *sc, const bool reflection, const bool transmission)
Definition bsdf.h:604
CCL_NAMESPACE_BEGIN ccl_device int bsdf_ashikhmin_shirley_setup(ccl_private MicrofacetBsdf *bsdf)
ccl_device int bsdf_ashikhmin_velvet_setup(ccl_private VelvetBsdf *bsdf)
ccl_device int bsdf_translucent_setup(ccl_private DiffuseBsdf *bsdf)
ccl_device int bsdf_diffuse_setup(ccl_private DiffuseBsdf *bsdf)
ccl_device int bsdf_hair_reflection_setup(ccl_private HairBsdf *bsdf)
Definition bsdf_hair.h:23
ccl_device int bsdf_hair_transmission_setup(ccl_private HairBsdf *bsdf)
Definition bsdf_hair.h:31
ccl_device void bsdf_microfacet_setup_fresnel_dielectric_tint(KernelGlobals kg, ccl_private MicrofacetBsdf *bsdf, ccl_private const ShaderData *sd, ccl_private FresnelDielectricTint *fresnel, const bool preserve_energy)
ccl_device int bsdf_microfacet_beckmann_glass_setup(ccl_private MicrofacetBsdf *bsdf)
ccl_device void bsdf_microfacet_setup_fresnel_conductor(KernelGlobals kg, ccl_private MicrofacetBsdf *bsdf, ccl_private const ShaderData *sd, ccl_private FresnelConductor *fresnel, const bool preserve_energy)
ccl_device int bsdf_microfacet_beckmann_setup(ccl_private MicrofacetBsdf *bsdf)
ccl_device void bsdf_microfacet_setup_fresnel_generalized_schlick(KernelGlobals kg, ccl_private MicrofacetBsdf *bsdf, ccl_private const ShaderData *sd, ccl_private FresnelGeneralizedSchlick *fresnel, const bool preserve_energy)
ccl_device int bsdf_microfacet_beckmann_refraction_setup(ccl_private MicrofacetBsdf *bsdf)
ccl_device int bsdf_microfacet_ggx_glass_setup(ccl_private MicrofacetBsdf *bsdf)
ccl_device int bsdf_microfacet_ggx_setup(ccl_private MicrofacetBsdf *bsdf)
ccl_device void bsdf_microfacet_setup_fresnel_constant(KernelGlobals kg, ccl_private MicrofacetBsdf *bsdf, ccl_private const ShaderData *sd, const Spectrum color)
ccl_device void bsdf_microfacet_setup_fresnel_f82_tint(KernelGlobals kg, ccl_private MicrofacetBsdf *bsdf, ccl_private const ShaderData *sd, ccl_private FresnelF82Tint *fresnel, const Spectrum f82_tint, const bool preserve_energy)
ccl_device int bsdf_microfacet_ggx_refraction_setup(ccl_private MicrofacetBsdf *bsdf)
ccl_device int bsdf_oren_nayar_setup(ccl_private const ShaderData *sd, ccl_private OrenNayarBsdf *bsdf, const Spectrum color)
ccl_device void bsdf_ray_portal_setup(ccl_private ShaderData *sd, const Spectrum weight, uint32_t path_flag, float3 position, float3 direction)
ccl_device int bsdf_sheen_setup(KernelGlobals kg, ccl_private const ShaderData *sd, ccl_private SheenBsdf *bsdf)
Definition bsdf_sheen.h:25
ccl_device int bsdf_diffuse_toon_setup(ccl_private ToonBsdf *bsdf)
Definition bsdf_toon.h:31
ccl_device int bsdf_glossy_toon_setup(ccl_private ToonBsdf *bsdf)
Definition bsdf_toon.h:113
CCL_NAMESPACE_BEGIN ccl_device void bsdf_transparent_setup(ccl_private ShaderData *sd, const Spectrum weight, uint32_t path_flag)
ccl_device float3 maybe_ensure_valid_specular_reflection(ccl_private ShaderData *sd, float3 N)
Definition bsdf_util.h:221
ccl_device float ior_from_F0(float f0)
Definition bsdf_util.h:106
ccl_device int bssrdf_setup(ccl_private ShaderData *sd, ccl_private Bssrdf *bssrdf, int path_flag, ClosureType type)
Definition bssrdf.h:283
ccl_device_inline ccl_private Bssrdf * bssrdf_alloc(ccl_private ShaderData *sd, Spectrum weight)
Definition bssrdf.h:265
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119
ccl_device void osl_closure_rayleigh_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const VolumeRayleighClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_microfacet_multi_ggx_aniso_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const MicrofacetMultiGGXClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_hair_transmission_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const HairTransmissionClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_phong_ramp_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t, float3 weight, ccl_private const PhongRampClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_ray_portal_bsdf_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const RayPortalBSDFClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_hair_chiang_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const ChiangHairClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_emission_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t, float3 weight, ccl_private const GenericEmissiveClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_generalized_schlick_bsdf_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const GeneralizedSchlickBSDFClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_diffuse_toon_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const DiffuseToonClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_microfacet_f82_tint_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const MicrofacetF82TintClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_holdout_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t, float3 weight, ccl_private const HoldoutClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_ashikhmin_velvet_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const AshikhminVelvetClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_background_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t, float3 weight, ccl_private const GenericBackgroundClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_hair_reflection_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const HairReflectionClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_sheen_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const SheenClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_translucent_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const TranslucentClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_hair_huang_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const HuangHairClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_transparent_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const TransparentClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_diffuse_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const DiffuseClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_reflection_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const ReflectionClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_microfacet_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const MicrofacetClosure *closure, float3 *layer_albedo)
ccl_device_forceinline bool osl_closure_skip(KernelGlobals kg, ccl_private const ShaderData *sd, uint32_t path_flag, int scattering)
ccl_device_forceinline void osl_zero_albedo(float3 *layer_albedo)
ccl_device void osl_closure_refraction_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const RefractionClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_bssrdf_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const BSSRDFClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_fournier_forand_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const VolumeFournierForandClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_henyey_greenstein_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const VolumeHenyeyGreensteinClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_oren_nayar_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const OrenNayarClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_oren_nayar_diffuse_bsdf_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const OrenNayarDiffuseBSDFClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_dielectric_bsdf_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const DielectricBSDFClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_diffuse_ramp_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t, float3 weight, ccl_private const DiffuseRampClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_glossy_toon_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const GlossyToonClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_draine_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const VolumeDraineClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_absorption_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const VolumeAbsorptionClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_conductor_bsdf_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const ConductorBSDFClosure *closure, float3 *layer_albedo)
ccl_device void osl_closure_microfacet_multi_ggx_glass_setup(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, float3 weight, ccl_private const MicrofacetMultiGGXGlassClosure *closure, float3 *layer_albedo)
const char * label
#define kernel_data
const KernelGlobalsCPU *ccl_restrict KernelGlobals
#define kernel_data_fetch(name, index)
#define ccl_device_forceinline
#define ccl_device
#define ccl_private
#define CCL_NAMESPACE_END
#define ccl_align(n)
#define NULL
ccl_device void emission_setup(ccl_private ShaderData *sd, const Spectrum weight)
Definition emissive.h:27
CCL_NAMESPACE_BEGIN ccl_device void background_setup(ccl_private ShaderData *sd, const Spectrum weight)
Definition emissive.h:14
uint top
#define mix(a, b, c)
Definition hash.h:36
CCL_NAMESPACE_BEGIN ccl_device void volume_extinction_setup(ccl_private ShaderData *sd, Spectrum weight)
ccl_device_inline float object_volume_density(KernelGlobals kg, int object)
ccl_device_inline DeviceString make_string(const char *str, size_t hash)
ClosureType
@ CLOSURE_BSSRDF_BURLEY_ID
@ CLOSURE_BSSRDF_RANDOM_WALK_ID
@ CLOSURE_HOLDOUT_ID
@ CLOSURE_BSSRDF_RANDOM_WALK_SKIN_ID
@ SD_IS_VOLUME_SHADER_EVAL
@ SD_HOLDOUT
@ PRIMITIVE_CURVE
@ PATH_RAY_DIFFUSE
@ PATH_RAY_CAMERA
#define PRIMITIVE_UNPACK_SEGMENT(type)
ShaderData
@ LABEL_TRANSMIT
@ LABEL_DIFFUSE
@ LABEL_SINGULAR
@ LABEL_GLOSSY
@ LABEL_REFLECT
ShaderClosure
ccl_device_inline Spectrum rgb_to_spectrum(float3 rgb)
ccl_device_inline bool is_zero(const float2 a)
ccl_device_inline float average(const float2 a)
ccl_device_inline float3 safe_normalize_fallback(const float3 a, const float3 fallback)
ccl_device_inline float3 one_float3()
Definition math_float3.h:24
CCL_NAMESPACE_BEGIN ccl_device_inline float3 zero_float3()
Definition math_float3.h:15
closure color bssrdf(string method, normal N, vector radius, color albedo) BUILTIN
unsigned int uint32_t
Definition stdint.h:80
Definition bssrdf.h:9
#define zero_spectrum
ccl_device int volume_draine_setup(ccl_private DraineVolume *volume)
ccl_device int volume_fournier_forand_setup(ccl_private FournierForandVolume *volume, float B, float IOR)
ccl_device int volume_henyey_greenstein_setup(ccl_private HenyeyGreensteinVolume *volume)
ccl_device int volume_rayleigh_setup(ccl_private RayleighVolume *volume)