diff options
author | Brecht Van Lommel <brecht@blender.org> | 2021-10-08 20:44:56 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2021-10-11 19:22:54 +0300 |
commit | a94343a8afcac5d6db09c8461e67ad1ba5a85d35 (patch) | |
tree | f56b8e6a956ca87f25b01f94b6f6421636448402 /intern/cycles/kernel | |
parent | 73a05ff9e83a31be34d32a92cd5fb4d17994e342 (diff) |
Cycles: improve SSS Fresnel and retro-reflection in Principled BSDF
For details see the "Extending the Disney BRDF to a BSDF with Integrated
Subsurface Scattering" paper.
We split the diffuse BSDF into a lambertian and retro-reflection component.
The retro-reflection component is always handled as a BSDF, while the
lambertian component can be replaced by a BSSRDF.
For the BSSRDF case, we compute Fresnel separately at the entry and exit
points, which may have different normals. As the scattering radius decreases
this converges to the BSDF case.
A downside is that this increases noise for subsurface scattering in the
Principled BSDF, due to some samples going to the retro-reflection component.
However the previous logic (also in 2.93) was simple wrong, using a
non-sensical view direction vector at the exit point. We use an importance
sampling weight estimate for the retro-reflection to try to better balance
samples between the BSDF and BSSRDF.
Differential Revision: https://developer.blender.org/D12801
Diffstat (limited to 'intern/cycles/kernel')
-rw-r--r-- | intern/cycles/kernel/closure/bsdf.h | 6 | ||||
-rw-r--r-- | intern/cycles/kernel/closure/bsdf_principled_diffuse.h | 78 | ||||
-rw-r--r-- | intern/cycles/kernel/closure/bssrdf.h | 30 | ||||
-rw-r--r-- | intern/cycles/kernel/integrator/integrator_shade_surface.h | 4 | ||||
-rw-r--r-- | intern/cycles/kernel/integrator/integrator_state_template.h | 1 | ||||
-rw-r--r-- | intern/cycles/kernel/integrator/integrator_subsurface.h | 44 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_shader.h | 11 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_types.h | 20 | ||||
-rw-r--r-- | intern/cycles/kernel/svm/svm_closure.h | 4 | ||||
-rw-r--r-- | intern/cycles/kernel/svm/svm_types.h | 4 |
10 files changed, 125 insertions, 77 deletions
diff --git a/intern/cycles/kernel/closure/bsdf.h b/intern/cycles/kernel/closure/bsdf.h index 4eb8bcae997..87aa6339f80 100644 --- a/intern/cycles/kernel/closure/bsdf.h +++ b/intern/cycles/kernel/closure/bsdf.h @@ -128,7 +128,6 @@ ccl_device_inline int bsdf_sample(const KernelGlobals *kg, switch (sc->type) { case CLOSURE_BSDF_DIFFUSE_ID: - case CLOSURE_BSDF_BSSRDF_ID: label = bsdf_diffuse_sample(sc, Ng, sd->I, @@ -401,7 +400,6 @@ ccl_device_inline int bsdf_sample(const KernelGlobals *kg, break; # ifdef __PRINCIPLED__ case CLOSURE_BSDF_PRINCIPLED_DIFFUSE_ID: - case CLOSURE_BSDF_BSSRDF_PRINCIPLED_ID: label = bsdf_principled_diffuse_sample(sc, Ng, sd->I, @@ -481,7 +479,6 @@ ccl_device_inline if (!is_transmission) { switch (sc->type) { case CLOSURE_BSDF_DIFFUSE_ID: - case CLOSURE_BSDF_BSSRDF_ID: eval = bsdf_diffuse_eval_reflect(sc, sd->I, omega_in, pdf); break; #ifdef __SVM__ @@ -550,7 +547,6 @@ ccl_device_inline break; # ifdef __PRINCIPLED__ case CLOSURE_BSDF_PRINCIPLED_DIFFUSE_ID: - case CLOSURE_BSDF_BSSRDF_PRINCIPLED_ID: eval = bsdf_principled_diffuse_eval_reflect(sc, sd->I, omega_in, pdf); break; case CLOSURE_BSDF_PRINCIPLED_SHEEN_ID: @@ -576,7 +572,6 @@ ccl_device_inline else { switch (sc->type) { case CLOSURE_BSDF_DIFFUSE_ID: - case CLOSURE_BSDF_BSSRDF_ID: eval = bsdf_diffuse_eval_transmit(sc, sd->I, omega_in, pdf); break; #ifdef __SVM__ @@ -637,7 +632,6 @@ ccl_device_inline break; # ifdef __PRINCIPLED__ case CLOSURE_BSDF_PRINCIPLED_DIFFUSE_ID: - case CLOSURE_BSDF_BSSRDF_PRINCIPLED_ID: eval = bsdf_principled_diffuse_eval_transmit(sc, sd->I, omega_in, pdf); break; case CLOSURE_BSDF_PRINCIPLED_SHEEN_ID: diff --git a/intern/cycles/kernel/closure/bsdf_principled_diffuse.h b/intern/cycles/kernel/closure/bsdf_principled_diffuse.h index 0d611f40096..04963ca1dc5 100644 --- a/intern/cycles/kernel/closure/bsdf_principled_diffuse.h +++ b/intern/cycles/kernel/closure/bsdf_principled_diffuse.h @@ -19,50 +19,98 @@ /* DISNEY PRINCIPLED DIFFUSE BRDF * * Shading model by Brent Burley (Disney): "Physically Based Shading at Disney" (2012) + * + * "Extending the Disney BRDF to a BSDF with Integrated Subsurface Scattering" (2015) + * For the separation of retro-reflection, "2.3 Dielectric BRDF with integrated + * subsurface scattering" */ #include "kernel/closure/bsdf_util.h" CCL_NAMESPACE_BEGIN +enum PrincipledDiffuseBsdfComponents { + PRINCIPLED_DIFFUSE_FULL = 1, + PRINCIPLED_DIFFUSE_LAMBERT = 2, + PRINCIPLED_DIFFUSE_LAMBERT_EXIT = 4, + PRINCIPLED_DIFFUSE_RETRO_REFLECTION = 8, +}; + typedef ccl_addr_space struct PrincipledDiffuseBsdf { SHADER_CLOSURE_BASE; float roughness; + int components; } PrincipledDiffuseBsdf; static_assert(sizeof(ShaderClosure) >= sizeof(PrincipledDiffuseBsdf), "PrincipledDiffuseBsdf is too large!"); -ccl_device float3 calculate_principled_diffuse_brdf( +ccl_device int bsdf_principled_diffuse_setup(PrincipledDiffuseBsdf *bsdf) +{ + bsdf->type = CLOSURE_BSDF_PRINCIPLED_DIFFUSE_ID; + return SD_BSDF | SD_BSDF_HAS_EVAL; +} + +ccl_device float3 bsdf_principled_diffuse_compute_brdf( const PrincipledDiffuseBsdf *bsdf, float3 N, float3 V, float3 L, float *pdf) { - float NdotL = dot(N, L); + const float NdotL = dot(N, L); if (NdotL <= 0) { return make_float3(0.0f, 0.0f, 0.0f); } - float NdotV = dot(N, V); + const float NdotV = dot(N, V); + + const float FV = schlick_fresnel(NdotV); + const float FL = schlick_fresnel(NdotL); + + float f = 0.0f; - /* H = normalize(L + V); // Bisector of an angle between L and V. - * LH2 = 2 * dot(L, H)^2 = 2cos(x)^2 = cos(2x) + 1 = dot(L, V) + 1, - * half-angle x between L and V is at most 90 deg - */ - float LH2 = dot(L, V) + 1; + /* Lambertian component. */ + if (bsdf->components & (PRINCIPLED_DIFFUSE_FULL | PRINCIPLED_DIFFUSE_LAMBERT)) { + f += (1.0f - 0.5f * FV) * (1.0f - 0.5f * FL); + } + else if (bsdf->components & PRINCIPLED_DIFFUSE_LAMBERT_EXIT) { + f += (1.0f - 0.5f * FL); + } - float FL = schlick_fresnel(NdotL), FV = schlick_fresnel(NdotV); - const float Fd90 = 0.5f + LH2 * bsdf->roughness; - float Fd = (1.0f - FL + Fd90 * FL) * (1.0f - FV + Fd90 * FV); + /* Retro-reflection component. */ + if (bsdf->components & (PRINCIPLED_DIFFUSE_FULL | PRINCIPLED_DIFFUSE_RETRO_REFLECTION)) { + /* H = normalize(L + V); // Bisector of an angle between L and V + * LH2 = 2 * dot(L, H)^2 = 2cos(x)^2 = cos(2x) + 1 = dot(L, V) + 1, + * half-angle x between L and V is at most 90 deg. */ + const float LH2 = dot(L, V) + 1; + const float RR = bsdf->roughness * LH2; + f += RR * (FL + FV + FL * FV * (RR - 1.0f)); + } - float value = M_1_PI_F * NdotL * Fd; + float value = M_1_PI_F * NdotL * f; return make_float3(value, value, value); } -ccl_device int bsdf_principled_diffuse_setup(PrincipledDiffuseBsdf *bsdf) +/* Compute Fresnel at entry point, to be compbined with PRINCIPLED_DIFFUSE_LAMBERT_EXIT + * at the exit point to get the complete BSDF. */ +ccl_device_inline float bsdf_principled_diffuse_compute_entry_fresnel(const float NdotV) +{ + const float FV = schlick_fresnel(NdotV); + return (1.0f - 0.5f * FV); +} + +/* Ad-hoc weight adjusment to avoid retro-reflection taking away half the + * samples from BSSRDF. */ +ccl_device_inline float bsdf_principled_diffuse_retro_reflection_sample_weight( + PrincipledDiffuseBsdf *bsdf, const float3 I) +{ + return bsdf->roughness * schlick_fresnel(dot(bsdf->N, I)); +} + +ccl_device int bsdf_principled_diffuse_setup(PrincipledDiffuseBsdf *bsdf, int components) { bsdf->type = CLOSURE_BSDF_PRINCIPLED_DIFFUSE_ID; + bsdf->components = components; return SD_BSDF | SD_BSDF_HAS_EVAL; } @@ -79,7 +127,7 @@ ccl_device float3 bsdf_principled_diffuse_eval_reflect(const ShaderClosure *sc, if (dot(N, omega_in) > 0.0f) { *pdf = fmaxf(dot(N, omega_in), 0.0f) * M_1_PI_F; - return calculate_principled_diffuse_brdf(bsdf, N, V, L, pdf); + return bsdf_principled_diffuse_compute_brdf(bsdf, N, V, L, pdf); } else { *pdf = 0.0f; @@ -115,7 +163,7 @@ ccl_device int bsdf_principled_diffuse_sample(const ShaderClosure *sc, sample_cos_hemisphere(N, randu, randv, omega_in, pdf); if (dot(Ng, *omega_in) > 0) { - *eval = calculate_principled_diffuse_brdf(bsdf, N, I, *omega_in, pdf); + *eval = bsdf_principled_diffuse_compute_brdf(bsdf, N, I, *omega_in, pdf); #ifdef __RAY_DIFFERENTIALS__ // TODO: find a better approximation for the diffuse bounce diff --git a/intern/cycles/kernel/closure/bssrdf.h b/intern/cycles/kernel/closure/bssrdf.h index db183887018..d2f8af7910c 100644 --- a/intern/cycles/kernel/closure/bssrdf.h +++ b/intern/cycles/kernel/closure/bssrdf.h @@ -277,10 +277,27 @@ ccl_device_inline Bssrdf *bssrdf_alloc(ShaderData *sd, float3 weight) ccl_device int bssrdf_setup(ShaderData *sd, Bssrdf *bssrdf, ClosureType type, const float ior) { int flag = 0; + + /* Add retro-reflection component as separate diffuse BSDF. */ + if (bssrdf->roughness != FLT_MAX) { + PrincipledDiffuseBsdf *bsdf = (PrincipledDiffuseBsdf *)bsdf_alloc( + sd, sizeof(PrincipledDiffuseBsdf), bssrdf->weight); + + if (bsdf) { + bsdf->N = bssrdf->N; + bsdf->roughness = bssrdf->roughness; + flag |= bsdf_principled_diffuse_setup(bsdf, PRINCIPLED_DIFFUSE_RETRO_REFLECTION); + + /* Ad-hoc weight adjusment to avoid retro-reflection taking away half the + * samples from BSSRDF. */ + bsdf->sample_weight *= bsdf_principled_diffuse_retro_reflection_sample_weight(bsdf, sd->I); + } + } + + /* Verify if the radii are large enough to sample without precision issues. */ int bssrdf_channels = 3; float3 diffuse_weight = make_float3(0.0f, 0.0f, 0.0f); - /* Verify if the radii are large enough to sample without precision issues. */ if (bssrdf->radius.x < BSSRDF_MIN_RADIUS) { diffuse_weight.x = bssrdf->weight.x; bssrdf->weight.x = 0.0f; @@ -304,17 +321,13 @@ ccl_device int bssrdf_setup(ShaderData *sd, Bssrdf *bssrdf, ClosureType type, co /* Add diffuse BSDF if any radius too small. */ #ifdef __PRINCIPLED__ if (bssrdf->roughness != FLT_MAX) { - float roughness = bssrdf->roughness; - float3 N = bssrdf->N; - PrincipledDiffuseBsdf *bsdf = (PrincipledDiffuseBsdf *)bsdf_alloc( sd, sizeof(PrincipledDiffuseBsdf), diffuse_weight); if (bsdf) { - bsdf->type = CLOSURE_BSDF_BSSRDF_PRINCIPLED_ID; - bsdf->N = N; - bsdf->roughness = roughness; - flag |= bsdf_principled_diffuse_setup(bsdf); + bsdf->N = bssrdf->N; + bsdf->roughness = bssrdf->roughness; + flag |= bsdf_principled_diffuse_setup(bsdf, PRINCIPLED_DIFFUSE_LAMBERT); } } else @@ -323,7 +336,6 @@ ccl_device int bssrdf_setup(ShaderData *sd, Bssrdf *bssrdf, ClosureType type, co DiffuseBsdf *bsdf = (DiffuseBsdf *)bsdf_alloc(sd, sizeof(DiffuseBsdf), diffuse_weight); if (bsdf) { - bsdf->type = CLOSURE_BSDF_BSSRDF_ID; bsdf->N = bssrdf->N; flag |= bsdf_diffuse_setup(bsdf); } diff --git a/intern/cycles/kernel/integrator/integrator_shade_surface.h b/intern/cycles/kernel/integrator/integrator_shade_surface.h index a24473addcc..27338f824c0 100644 --- a/intern/cycles/kernel/integrator/integrator_shade_surface.h +++ b/intern/cycles/kernel/integrator/integrator_shade_surface.h @@ -378,11 +378,11 @@ ccl_device bool integrate_surface(INTEGRATOR_STATE_ARGS, } #ifdef __SUBSURFACE__ - if (INTEGRATOR_STATE(path, flag) & PATH_RAY_SUBSURFACE) { + if (path_flag & PATH_RAY_SUBSURFACE) { /* When coming from inside subsurface scattering, setup a diffuse * closure to perform lighting at the exit point. */ + subsurface_shader_data_setup(INTEGRATOR_STATE_PASS, &sd, path_flag); INTEGRATOR_STATE_WRITE(path, flag) &= ~PATH_RAY_SUBSURFACE; - subsurface_shader_data_setup(INTEGRATOR_STATE_PASS, &sd); } #endif diff --git a/intern/cycles/kernel/integrator/integrator_state_template.h b/intern/cycles/kernel/integrator/integrator_state_template.h index 15998ee6edf..0fe47cf13bc 100644 --- a/intern/cycles/kernel/integrator/integrator_state_template.h +++ b/intern/cycles/kernel/integrator/integrator_state_template.h @@ -99,7 +99,6 @@ KERNEL_STRUCT_BEGIN(subsurface) KERNEL_STRUCT_MEMBER(subsurface, float3, albedo, KERNEL_FEATURE_SUBSURFACE) KERNEL_STRUCT_MEMBER(subsurface, float3, radius, KERNEL_FEATURE_SUBSURFACE) KERNEL_STRUCT_MEMBER(subsurface, float, anisotropy, KERNEL_FEATURE_SUBSURFACE) -KERNEL_STRUCT_MEMBER(subsurface, float, roughness, KERNEL_FEATURE_SUBSURFACE) KERNEL_STRUCT_END(subsurface) /********************************** Volume Stack ******************************/ diff --git a/intern/cycles/kernel/integrator/integrator_subsurface.h b/intern/cycles/kernel/integrator/integrator_subsurface.h index 7ca676351db..2d15c82322a 100644 --- a/intern/cycles/kernel/integrator/integrator_subsurface.h +++ b/intern/cycles/kernel/integrator/integrator_subsurface.h @@ -47,7 +47,7 @@ ccl_device int subsurface_bounce(INTEGRATOR_STATE_ARGS, ShaderData *sd, const Sh /* Setup ray into surface. */ INTEGRATOR_STATE_WRITE(ray, P) = sd->P; - INTEGRATOR_STATE_WRITE(ray, D) = sd->N; + INTEGRATOR_STATE_WRITE(ray, D) = bssrdf->N; INTEGRATOR_STATE_WRITE(ray, t) = FLT_MAX; INTEGRATOR_STATE_WRITE(ray, dP) = differential_make_compact(sd->dP); INTEGRATOR_STATE_WRITE(ray, dD) = differential_zero_compact(); @@ -56,13 +56,20 @@ ccl_device int subsurface_bounce(INTEGRATOR_STATE_ARGS, ShaderData *sd, const Sh INTEGRATOR_STATE_WRITE(isect, Ng) = sd->Ng; INTEGRATOR_STATE_WRITE(isect, object) = sd->object; - /* Pass BSSRDF parameters. */ - const uint32_t path_flag = INTEGRATOR_STATE_WRITE(path, flag); - INTEGRATOR_STATE_WRITE(path, flag) = (path_flag & ~PATH_RAY_CAMERA) | - ((sc->type == CLOSURE_BSSRDF_BURLEY_ID) ? - PATH_RAY_SUBSURFACE_DISK : - PATH_RAY_SUBSURFACE_RANDOM_WALK); - INTEGRATOR_STATE_WRITE(path, throughput) *= shader_bssrdf_sample_weight(sd, sc); + uint32_t path_flag = (INTEGRATOR_STATE(path, flag) & ~PATH_RAY_CAMERA) | + ((sc->type == CLOSURE_BSSRDF_BURLEY_ID) ? PATH_RAY_SUBSURFACE_DISK : + PATH_RAY_SUBSURFACE_RANDOM_WALK); + + /* Compute weight, optionally including Fresnel from entry point. */ + float3 weight = shader_bssrdf_sample_weight(sd, sc); +# ifdef __PRINCIPLED__ + if (bssrdf->roughness != FLT_MAX) { + path_flag |= PATH_RAY_SUBSURFACE_USE_FRESNEL; + } +# endif + + INTEGRATOR_STATE_WRITE(path, throughput) *= weight; + INTEGRATOR_STATE_WRITE(path, flag) = path_flag; /* Advance random number offset for bounce. */ INTEGRATOR_STATE_WRITE(path, rng_offset) += PRNG_BOUNCE_NUM; @@ -73,15 +80,17 @@ ccl_device int subsurface_bounce(INTEGRATOR_STATE_ARGS, ShaderData *sd, const Sh } } + /* Pass BSSRDF parameters. */ INTEGRATOR_STATE_WRITE(subsurface, albedo) = bssrdf->albedo; INTEGRATOR_STATE_WRITE(subsurface, radius) = bssrdf->radius; - INTEGRATOR_STATE_WRITE(subsurface, roughness) = bssrdf->roughness; INTEGRATOR_STATE_WRITE(subsurface, anisotropy) = bssrdf->anisotropy; return LABEL_SUBSURFACE_SCATTER; } -ccl_device void subsurface_shader_data_setup(INTEGRATOR_STATE_ARGS, ShaderData *sd) +ccl_device void subsurface_shader_data_setup(INTEGRATOR_STATE_ARGS, + ShaderData *sd, + const uint32_t path_flag) { /* Get bump mapped normal from shader evaluation at exit point. */ float3 N = sd->N; @@ -95,21 +104,16 @@ ccl_device void subsurface_shader_data_setup(INTEGRATOR_STATE_ARGS, ShaderData * sd->num_closure_left = kernel_data.max_closures; const float3 weight = one_float3(); - const float roughness = INTEGRATOR_STATE(subsurface, roughness); # ifdef __PRINCIPLED__ - if (roughness != FLT_MAX) { + if (path_flag & PATH_RAY_SUBSURFACE_USE_FRESNEL) { PrincipledDiffuseBsdf *bsdf = (PrincipledDiffuseBsdf *)bsdf_alloc( sd, sizeof(PrincipledDiffuseBsdf), weight); if (bsdf) { bsdf->N = N; - bsdf->roughness = roughness; - sd->flag |= bsdf_principled_diffuse_setup(bsdf); - - /* replace CLOSURE_BSDF_PRINCIPLED_DIFFUSE_ID with this special ID so render passes - * can recognize it as not being a regular Disney principled diffuse closure */ - bsdf->type = CLOSURE_BSDF_BSSRDF_PRINCIPLED_ID; + bsdf->roughness = FLT_MAX; + sd->flag |= bsdf_principled_diffuse_setup(bsdf, PRINCIPLED_DIFFUSE_LAMBERT_EXIT); } } else @@ -120,10 +124,6 @@ ccl_device void subsurface_shader_data_setup(INTEGRATOR_STATE_ARGS, ShaderData * if (bsdf) { bsdf->N = N; sd->flag |= bsdf_diffuse_setup(bsdf); - - /* replace CLOSURE_BSDF_DIFFUSE_ID with this special ID so render passes - * can recognize it as not being a regular diffuse closure */ - bsdf->type = CLOSURE_BSDF_BSSRDF_ID; } } } diff --git a/intern/cycles/kernel/kernel_shader.h b/intern/cycles/kernel/kernel_shader.h index a50f3fb214b..d1b53832793 100644 --- a/intern/cycles/kernel/kernel_shader.h +++ b/intern/cycles/kernel/kernel_shader.h @@ -159,7 +159,7 @@ ccl_device_forceinline bool _shader_bsdf_exclude(ClosureType type, uint light_sh return false; } if (light_shader_flags & SHADER_EXCLUDE_DIFFUSE) { - if (CLOSURE_IS_BSDF_DIFFUSE(type) || CLOSURE_IS_BSDF_BSSRDF(type)) { + if (CLOSURE_IS_BSDF_DIFFUSE(type)) { return true; } } @@ -201,8 +201,7 @@ ccl_device_inline float _shader_bsdf_multi_eval(const KernelGlobals *kg, float3 eval = bsdf_eval(kg, sd, sc, omega_in, is_transmission, &bsdf_pdf); if (bsdf_pdf != 0.0f) { - const bool is_diffuse = (CLOSURE_IS_BSDF_DIFFUSE(sc->type) || - CLOSURE_IS_BSDF_BSSRDF(sc->type)); + const bool is_diffuse = CLOSURE_IS_BSDF_DIFFUSE(sc->type); bsdf_eval_accum(result_eval, is_diffuse, eval * sc->weight, 1.0f); sum_pdf += bsdf_pdf * sc->sample_weight; } @@ -320,8 +319,7 @@ ccl_device int shader_bsdf_sample_closure(const KernelGlobals *kg, label = bsdf_sample(kg, sd, sc, randu, randv, &eval, omega_in, domega_in, pdf); if (*pdf != 0.0f) { - const bool is_diffuse = (CLOSURE_IS_BSDF_DIFFUSE(sc->type) || - CLOSURE_IS_BSDF_BSSRDF(sc->type)); + const bool is_diffuse = CLOSURE_IS_BSDF_DIFFUSE(sc->type); bsdf_eval_init(bsdf_eval, is_diffuse, eval * sc->weight); if (sd->num_closure > 1) { @@ -401,8 +399,7 @@ ccl_device float3 shader_bsdf_diffuse(const KernelGlobals *kg, const ShaderData for (int i = 0; i < sd->num_closure; i++) { const ShaderClosure *sc = &sd->closure[i]; - if (CLOSURE_IS_BSDF_DIFFUSE(sc->type) || CLOSURE_IS_BSSRDF(sc->type) || - CLOSURE_IS_BSDF_BSSRDF(sc->type)) + if (CLOSURE_IS_BSDF_DIFFUSE(sc->type) || CLOSURE_IS_BSSRDF(sc->type)) eval += sc->weight; } diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index eb681683d6a..00457695e53 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -263,32 +263,34 @@ enum PathRayFlag { /* Perform subsurface scattering. */ PATH_RAY_SUBSURFACE_RANDOM_WALK = (1 << 20), PATH_RAY_SUBSURFACE_DISK = (1 << 21), - PATH_RAY_SUBSURFACE = (PATH_RAY_SUBSURFACE_RANDOM_WALK | PATH_RAY_SUBSURFACE_DISK), + PATH_RAY_SUBSURFACE_USE_FRESNEL = (1 << 22), + PATH_RAY_SUBSURFACE = (PATH_RAY_SUBSURFACE_RANDOM_WALK | PATH_RAY_SUBSURFACE_DISK | + PATH_RAY_SUBSURFACE_USE_FRESNEL), /* Contribute to denoising features. */ - PATH_RAY_DENOISING_FEATURES = (1 << 22), + PATH_RAY_DENOISING_FEATURES = (1 << 23), /* Render pass categories. */ - PATH_RAY_REFLECT_PASS = (1 << 23), - PATH_RAY_TRANSMISSION_PASS = (1 << 24), - PATH_RAY_VOLUME_PASS = (1 << 25), + PATH_RAY_REFLECT_PASS = (1 << 24), + PATH_RAY_TRANSMISSION_PASS = (1 << 25), + PATH_RAY_VOLUME_PASS = (1 << 26), PATH_RAY_ANY_PASS = (PATH_RAY_REFLECT_PASS | PATH_RAY_TRANSMISSION_PASS | PATH_RAY_VOLUME_PASS), /* Shadow ray is for a light or surface. */ - PATH_RAY_SHADOW_FOR_LIGHT = (1 << 26), + PATH_RAY_SHADOW_FOR_LIGHT = (1 << 27), /* A shadow catcher object was hit and the path was split into two. */ - PATH_RAY_SHADOW_CATCHER_HIT = (1 << 27), + PATH_RAY_SHADOW_CATCHER_HIT = (1 << 28), /* A shadow catcher object was hit and this path traces only shadow catchers, writing them into * their dedicated pass for later division. * * NOTE: Is not covered with `PATH_RAY_ANY_PASS` because shadow catcher does special handling * which is separate from the light passes. */ - PATH_RAY_SHADOW_CATCHER_PASS = (1 << 28), + PATH_RAY_SHADOW_CATCHER_PASS = (1 << 29), /* Path is evaluating background for an approximate shadow catcher with non-transparent film. */ - PATH_RAY_SHADOW_CATCHER_BACKGROUND = (1 << 29), + PATH_RAY_SHADOW_CATCHER_BACKGROUND = (1 << 30), }; /* Configure ray visibility bits for rays and objects respectively, diff --git a/intern/cycles/kernel/svm/svm_closure.h b/intern/cycles/kernel/svm/svm_closure.h index b3f7fee8a63..e55f76a4400 100644 --- a/intern/cycles/kernel/svm/svm_closure.h +++ b/intern/cycles/kernel/svm/svm_closure.h @@ -221,7 +221,7 @@ ccl_device_noinline int svm_node_closure_bsdf( bsdf->roughness = roughness; /* setup bsdf */ - sd->flag |= bsdf_principled_diffuse_setup(bsdf); + sd->flag |= bsdf_principled_diffuse_setup(bsdf, PRINCIPLED_DIFFUSE_FULL); } } else if (subsurface > CLOSURE_WEIGHT_CUTOFF) { @@ -255,7 +255,7 @@ ccl_device_noinline int svm_node_closure_bsdf( bsdf->roughness = roughness; /* setup bsdf */ - sd->flag |= bsdf_principled_diffuse_setup(bsdf); + sd->flag |= bsdf_principled_diffuse_setup(bsdf, PRINCIPLED_DIFFUSE_FULL); } } # endif diff --git a/intern/cycles/kernel/svm/svm_types.h b/intern/cycles/kernel/svm/svm_types.h index e846e4af259..6f6c101fb69 100644 --- a/intern/cycles/kernel/svm/svm_types.h +++ b/intern/cycles/kernel/svm/svm_types.h @@ -538,8 +538,6 @@ typedef enum ClosureType { CLOSURE_BSDF_HAIR_TRANSMISSION_ID, /* Special cases */ - CLOSURE_BSDF_BSSRDF_ID, - CLOSURE_BSDF_BSSRDF_PRINCIPLED_ID, CLOSURE_BSDF_TRANSPARENT_ID, /* BSSRDF */ @@ -569,8 +567,6 @@ typedef enum ClosureType { (type == CLOSURE_BSDF_HAIR_PRINCIPLED_ID)) #define CLOSURE_IS_BSDF_TRANSMISSION(type) \ (type >= CLOSURE_BSDF_REFRACTION_ID && type <= CLOSURE_BSDF_HAIR_TRANSMISSION_ID) -#define CLOSURE_IS_BSDF_BSSRDF(type) \ - (type == CLOSURE_BSDF_BSSRDF_ID || type == CLOSURE_BSDF_BSSRDF_PRINCIPLED_ID) #define CLOSURE_IS_BSDF_SINGULAR(type) \ (type == CLOSURE_BSDF_REFLECTION_ID || type == CLOSURE_BSDF_REFRACTION_ID || \ type == CLOSURE_BSDF_TRANSPARENT_ID) |