18#define OSL_CLOSURE_STRUCT_BEGIN(Upper, lower) \
19 struct ccl_align(8) Upper##Closure \
22#define OSL_CLOSURE_STRUCT_END(Upper, lower) \
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];
42 if (layer_albedo !=
NULL) {
56 const bool reflect_caustics_disabled = !
kernel_data.integrator.caustics_reflective;
57 const bool refract_caustics_disabled = !
kernel_data.integrator.caustics_refractive;
60 if (reflect_caustics_disabled && has_reflect && !has_transmit) {
64 if (refract_caustics_disabled && has_transmit && !has_reflect) {
68 if (reflect_caustics_disabled && refract_caustics_disabled) {
119 bsdf->roughness = closure->roughness;
129 ccl_private const OrenNayarDiffuseBSDFClosure *closure,
143 bsdf->roughness = closure->roughness;
188 bsdf->alpha_x = bsdf->alpha_y = 0.0f;
211 bsdf->ior = closure->ior;
212 bsdf->alpha_x = bsdf->alpha_y = 0.0f;
235 sd,
rgb_to_spectrum(weight), path_flag, closure->position, closure->direction);
248 const bool has_reflection = !
is_zero(closure->reflection_tint);
249 const bool has_transmission = !
is_zero(closure->transmission_tint);
268 bsdf->alpha_x = closure->alpha_x;
269 bsdf->alpha_y = closure->alpha_y;
270 bsdf->ior = closure->ior;
271 bsdf->T = closure->T;
273 bool preserve_energy =
false;
276 if (closure->distribution ==
make_string(
"beckmann", 14712237670914973463ull)) {
277 if (has_reflection && has_transmission) {
280 else if (has_transmission) {
289 if (has_reflection && has_transmission) {
292 else if (has_transmission) {
299 preserve_energy = (closure->distribution ==
make_string(
"multi_ggx", 16842698693386468366ull));
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;
308 if (layer_albedo !=
NULL) {
309 if (has_reflection && !has_transmission) {
342 bsdf->alpha_x = closure->alpha_x;
343 bsdf->alpha_y = closure->alpha_y;
345 bsdf->T = closure->T;
347 bool preserve_energy =
false;
350 if (closure->distribution ==
make_string(
"beckmann", 14712237670914973463ull)) {
356 preserve_energy = (closure->distribution ==
make_string(
"multi_ggx", 16842698693386468366ull));
369 ccl_private const GeneralizedSchlickBSDFClosure *closure,
374 const bool has_reflection = !
is_zero(closure->reflection_tint);
375 const bool has_transmission = !
is_zero(closure->transmission_tint);
378 if (has_transmission) {
399 bsdf->alpha_x = closure->alpha_x;
400 bsdf->alpha_y = closure->alpha_y;
401 bsdf->T = closure->T;
403 if (closure->exponent < 0.0f) {
408 bsdf->ior = -closure->exponent;
414 bool preserve_energy =
false;
417 if (closure->distribution ==
make_string(
"beckmann", 14712237670914973463ull)) {
418 if (has_reflection && has_transmission) {
421 else if (has_transmission) {
430 if (has_reflection && has_transmission) {
433 else if (has_transmission) {
440 preserve_energy = (closure->distribution ==
make_string(
"multi_ggx", 16842698693386468366ull));
443 const bool reflective_caustics = (
kernel_data.integrator.caustics_reflective ||
445 const bool refractive_caustics = (
kernel_data.integrator.caustics_refractive ||
448 fresnel->reflection_tint = reflective_caustics ?
rgb_to_spectrum(closure->reflection_tint) :
450 fresnel->transmission_tint = refractive_caustics ?
rgb_to_spectrum(closure->transmission_tint) :
454 fresnel->exponent = closure->exponent;
455 fresnel->thin_film.thickness = closure->thinfilm_thickness;
456 fresnel->thin_film.ior = closure->thinfilm_ior;
459 if (layer_albedo !=
NULL) {
460 if (has_reflection && !has_transmission) {
492 bsdf->alpha_x = closure->alpha_x;
493 bsdf->alpha_y = closure->alpha_y;
494 bsdf->ior = closure->ior;
495 bsdf->T = closure->T;
498 if (closure->distribution ==
make_string(
"beckmann", 14712237670914973463ull)) {
499 if (closure->refract == 1) {
502 else if (closure->refract == 2) {
510 else if (closure->distribution ==
make_string(
"ashikhmin_shirley", 11318482998918370922ull)) {
515 if (closure->refract == 1) {
518 else if (closure->refract == 2) {
525 if (closure->distribution ==
make_string(
"multi_ggx", 16842698693386468366ull)) {
531 if (layer_albedo !=
NULL) {
532 if (closure->refract == 0) {
548 ccl_private const MicrofacetF82TintClosure *closure,
568 bsdf->alpha_x = closure->alpha_x;
569 bsdf->alpha_y = closure->alpha_y;
571 bsdf->T = closure->T;
573 bool preserve_energy =
false;
576 if (closure->distribution ==
make_string(
"beckmann", 14712237670914973463ull)) {
582 preserve_energy = (closure->distribution ==
make_string(
"multi_ggx", 16842698693386468366ull));
587 kg, bsdf, sd, fresnel,
rgb_to_spectrum(closure->f82), preserve_energy);
595 ccl_private const MicrofacetMultiGGXGlassClosure *closure,
612 bsdf->alpha_x = closure->alpha_x;
613 bsdf->alpha_y = bsdf->alpha_x;
614 bsdf->ior = closure->ior;
627 ccl_private const MicrofacetMultiGGXClosure *closure,
643 bsdf->alpha_x = closure->alpha_x;
644 bsdf->alpha_y = closure->alpha_y;
647 bsdf->T = closure->T;
652 if (layer_albedo !=
NULL) {
678 bsdf->sigma = closure->sigma;
705 bsdf->roughness = closure->roughness;
710 sd->flag |= sheen_flag;
712 if (layer_albedo !=
NULL) {
713 *layer_albedo = bsdf->weight;
736 bsdf->size = closure->size;
737 bsdf->smooth = closure->smooth;
760 bsdf->size = closure->size;
761 bsdf->smooth = closure->smooth;
794 ccl_private const GenericBackgroundClosure *closure,
837 for (
int i = 0; i < 8; i++) {
838 bsdf->colors[i] = closure->colors[i];
841 sd->flag |= bsdf_diffuse_ramp_setup(bsdf);
858 bsdf->exponent = closure->exponent;
865 for (
int i = 0; i < 8; i++) {
866 bsdf->colors[i] = closure->colors[i];
869 sd->flag |= bsdf_phong_ramp_setup(bsdf);
880 if (closure->method ==
make_string(
"burley", 186330084368958868ull)) {
883 else if (closure->method ==
make_string(
"random_walk", 11360609267673527222ull)) {
886 else if (closure->method ==
make_string(
"random_walk_skin", 3096325052680726300ull)) {
898 bssrdf->radius = closure->radius;
901 bssrdf->albedo = closure->albedo;
904 bssrdf->alpha = closure->roughness;
905 bssrdf->ior = closure->ior;
906 bssrdf->anisotropy = closure->anisotropy;
931 bsdf->T = closure->T;
932 bsdf->roughness1 = closure->roughness1;
933 bsdf->roughness2 = closure->roughness2;
934 bsdf->offset = closure->offset;
944 ccl_private const HairTransmissionClosure *closure,
958 bsdf->T = closure->T;
959 bsdf->roughness1 = closure->roughness1;
960 bsdf->roughness2 = closure->roughness2;
961 bsdf->offset = closure->offset;
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;
992 sd->flag |= bsdf_hair_chiang_setup(sd, bsdf);
1008 if (closure->r_lobe <= 0.0f && closure->tt_lobe <= 0.0f && closure->trt_lobe <= 0.0f) {
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;
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;
1036 bsdf->extra->pixel_coverage = 1.0f;
1044 const int k1 = k0 + 1;
1045 const float radius =
mix(
1048 bsdf->extra->pixel_coverage = 0.5f * sd->dP / radius;
1051 sd->flag |= bsdf_hair_huang_setup(sd, bsdf, path_flag);
1061 ccl_private const VolumeAbsorptionClosure *closure,
1072 ccl_private const VolumeHenyeyGreensteinClosure *closure,
1084 volume->
g = closure->g;
1094 ccl_private const VolumeFournierForandClosure *closure,
1123 volume->
g = closure->g;
1124 volume->alpha = closure->alpha;
ccl_device_inline ccl_private ShaderClosure * bsdf_alloc(ccl_private ShaderData *sd, int size, Spectrum weight)
ccl_device ccl_private void * closure_alloc_extra(ccl_private ShaderData *sd, int size)
CCL_NAMESPACE_BEGIN ccl_device ccl_private ShaderClosure * closure_alloc(ccl_private ShaderData *sd, int size, ClosureType type, Spectrum weight)
ccl_device_inline Spectrum bsdf_albedo(KernelGlobals kg, ccl_private const ShaderData *sd, ccl_private const ShaderClosure *sc, const bool reflection, const bool transmission)
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)
ccl_device int bsdf_hair_transmission_setup(ccl_private HairBsdf *bsdf)
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)
ccl_device int bsdf_diffuse_toon_setup(ccl_private ToonBsdf *bsdf)
ccl_device int bsdf_glossy_toon_setup(ccl_private ToonBsdf *bsdf)
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)
ccl_device float ior_from_F0(float f0)
ccl_device int bssrdf_setup(ccl_private ShaderData *sd, ccl_private Bssrdf *bssrdf, int path_flag, ClosureType type)
ccl_device_inline ccl_private Bssrdf * bssrdf_alloc(ccl_private ShaderData *sd, Spectrum weight)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
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 KernelGlobalsCPU *ccl_restrict KernelGlobals
#define kernel_data_fetch(name, index)
#define ccl_device_forceinline
#define CCL_NAMESPACE_END
ccl_device void emission_setup(ccl_private ShaderData *sd, const Spectrum weight)
CCL_NAMESPACE_BEGIN ccl_device void background_setup(ccl_private ShaderData *sd, const Spectrum weight)
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)
@ CLOSURE_BSSRDF_BURLEY_ID
@ CLOSURE_BSSRDF_RANDOM_WALK_ID
@ CLOSURE_BSSRDF_RANDOM_WALK_SKIN_ID
@ SD_IS_VOLUME_SHADER_EVAL
#define PRIMITIVE_UNPACK_SEGMENT(type)
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()
CCL_NAMESPACE_BEGIN ccl_device_inline float3 zero_float3()
closure color bssrdf(string method, normal N, vector radius, color albedo) BUILTIN
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)