Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/osl/closures_setup.h
| Show All 34 Lines | |||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| #define OSL_CLOSURE_STRUCT_BEGIN(Upper, lower) \ | #define OSL_CLOSURE_STRUCT_BEGIN(Upper, lower) \ | ||||
| struct ccl_align(8) Upper##Closure \ | struct ccl_align(8) Upper##Closure \ | ||||
| { \ | { \ | ||||
| const char *label; | const char *label; | ||||
| #define OSL_CLOSURE_STRUCT_END(Upper, lower) \ | #define OSL_CLOSURE_STRUCT_END(Upper, lower) \ | ||||
| } \ | } \ | ||||
| ; \ | ; | ||||
| ccl_device void osl_closure_##lower##_setup(KernelGlobals kg, \ | |||||
| ccl_private ShaderData *sd, \ | |||||
| uint32_t path_flag, \ | |||||
| float3 weight, \ | |||||
| ccl_private Upper##Closure *closure); | |||||
| #define OSL_CLOSURE_STRUCT_MEMBER(Upper, TYPE, type, name, key) type name; | #define OSL_CLOSURE_STRUCT_MEMBER(Upper, TYPE, type, name, key) type name; | ||||
| #define OSL_CLOSURE_STRUCT_ARRAY_MEMBER(Upper, TYPE, type, name, key, size) type name[size]; | #define OSL_CLOSURE_STRUCT_ARRAY_MEMBER(Upper, TYPE, type, name, key, size) type name[size]; | ||||
| #include "closures_template.h" | #include "closures_template.h" | ||||
| ccl_device_forceinline bool osl_closure_skip(KernelGlobals kg, | ccl_device_forceinline bool osl_closure_skip(KernelGlobals kg, | ||||
| ccl_private const ShaderData *sd, | ccl_private const ShaderData *sd, | ||||
| uint32_t path_flag, | uint32_t path_flag, | ||||
| ▲ Show 20 Lines • Show All 148 Lines • ▼ Show 20 Lines | ccl_device void osl_closure_microfacet_setup(KernelGlobals kg, | ||||
| } | } | ||||
| bsdf->N = ensure_valid_reflection(sd->Ng, sd->I, closure->N); | bsdf->N = ensure_valid_reflection(sd->Ng, sd->I, closure->N); | ||||
| bsdf->alpha_x = closure->alpha_x; | bsdf->alpha_x = closure->alpha_x; | ||||
| bsdf->alpha_y = closure->alpha_y; | bsdf->alpha_y = closure->alpha_y; | ||||
| bsdf->ior = closure->ior; | bsdf->ior = closure->ior; | ||||
| bsdf->T = closure->T; | bsdf->T = closure->T; | ||||
| static OSL::ustring u_ggx("ggx"); | |||||
| static OSL::ustring u_default("default"); | |||||
| /* GGX */ | /* GGX */ | ||||
| if (closure->distribution == u_ggx || closure->distribution == u_default) { | if (closure->distribution == make_string("ggx", 11253504724482777663ull) || | ||||
| closure->distribution == make_string("default", 4430693559278735917ull)) { | |||||
| if (!closure->refract) { | if (!closure->refract) { | ||||
| if (closure->alpha_x == closure->alpha_y) { | if (closure->alpha_x == closure->alpha_y) { | ||||
| /* Isotropic */ | /* Isotropic */ | ||||
| sd->flag |= bsdf_microfacet_ggx_isotropic_setup(bsdf); | sd->flag |= bsdf_microfacet_ggx_isotropic_setup(bsdf); | ||||
| } | } | ||||
| else { | else { | ||||
| /* Anisotropic */ | /* Anisotropic */ | ||||
| sd->flag |= bsdf_microfacet_ggx_setup(bsdf); | sd->flag |= bsdf_microfacet_ggx_setup(bsdf); | ||||
| ▲ Show 20 Lines • Show All 769 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| ccl_device void osl_closure_bssrdf_setup(KernelGlobals kg, | ccl_device void osl_closure_bssrdf_setup(KernelGlobals kg, | ||||
| ccl_private ShaderData *sd, | ccl_private ShaderData *sd, | ||||
| uint32_t path_flag, | uint32_t path_flag, | ||||
| float3 weight, | float3 weight, | ||||
| ccl_private const BSSRDFClosure *closure) | ccl_private const BSSRDFClosure *closure) | ||||
| { | { | ||||
| static ustring u_burley("burley"); | |||||
| static ustring u_random_walk_fixed_radius("random_walk_fixed_radius"); | |||||
| static ustring u_random_walk("random_walk"); | |||||
| ClosureType type; | ClosureType type; | ||||
| if (closure->method == u_burley) { | if (closure->method == make_string("burley", 186330084368958868ull)) { | ||||
| type = CLOSURE_BSSRDF_BURLEY_ID; | type = CLOSURE_BSSRDF_BURLEY_ID; | ||||
| } | } | ||||
| else if (closure->method == u_random_walk_fixed_radius) { | else if (closure->method == make_string("random_walk_fixed_radius", 5695810351010063150ull)) { | ||||
| type = CLOSURE_BSSRDF_RANDOM_WALK_FIXED_RADIUS_ID; | type = CLOSURE_BSSRDF_RANDOM_WALK_FIXED_RADIUS_ID; | ||||
| } | } | ||||
| else if (closure->method == u_random_walk) { | else if (closure->method == make_string("random_walk", 11360609267673527222ull)) { | ||||
| type = CLOSURE_BSSRDF_RANDOM_WALK_ID; | type = CLOSURE_BSSRDF_RANDOM_WALK_ID; | ||||
| } | } | ||||
| else { | else { | ||||
| return; | return; | ||||
| } | } | ||||
| ccl_private Bssrdf *bssrdf = bssrdf_alloc(sd, rgb_to_spectrum(weight)); | ccl_private Bssrdf *bssrdf = bssrdf_alloc(sd, rgb_to_spectrum(weight)); | ||||
| if (!bssrdf) { | if (!bssrdf) { | ||||
| ▲ Show 20 Lines • Show All 144 Lines • Show Last 20 Lines | |||||