Cycles: Separate the caustics controls for Generalized Schlick
This allows users to turn off reflective and refractive caustics separately from each other when using the Generalized Schlick material. This will impact the Principled BSDF and Glass BSDF, along with some custom OSL scripts. Pull Request: https://projects.blender.org/blender/blender/pulls/117617
This commit is contained in:
parent
6ab800c5a8
commit
58b9240c82
|
@ -63,7 +63,7 @@ ccl_device_forceinline bool osl_closure_skip(KernelGlobals kg,
|
|||
return true;
|
||||
}
|
||||
/* Glass Caustics */
|
||||
if (reflect_caustics_disabled && refract_caustics_disabled && has_reflect && has_transmit) {
|
||||
if (reflect_caustics_disabled && refract_caustics_disabled) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -400,8 +400,15 @@ ccl_device void osl_closure_generalized_schlick_bsdf_setup(
|
|||
preserve_energy = (closure->distribution == make_string("multi_ggx", 16842698693386468366ull));
|
||||
}
|
||||
|
||||
fresnel->reflection_tint = rgb_to_spectrum(closure->reflection_tint);
|
||||
fresnel->transmission_tint = rgb_to_spectrum(closure->transmission_tint);
|
||||
const bool reflective_caustics = (kernel_data.integrator.caustics_reflective ||
|
||||
(path_flag & PATH_RAY_DIFFUSE) == 0);
|
||||
const bool refractive_caustics = (kernel_data.integrator.caustics_refractive ||
|
||||
(path_flag & PATH_RAY_DIFFUSE) == 0);
|
||||
|
||||
fresnel->reflection_tint = reflective_caustics ? rgb_to_spectrum(closure->reflection_tint) :
|
||||
zero_spectrum();
|
||||
fresnel->transmission_tint = refractive_caustics ? rgb_to_spectrum(closure->transmission_tint) :
|
||||
zero_spectrum();
|
||||
fresnel->f0 = rgb_to_spectrum(closure->f0);
|
||||
fresnel->f90 = rgb_to_spectrum(closure->f90);
|
||||
fresnel->exponent = closure->exponent;
|
||||
|
|
|
@ -176,12 +176,11 @@ ccl_device
|
|||
#ifdef __CAUSTICS_TRICKS__
|
||||
const bool reflective_caustics = (kernel_data.integrator.caustics_reflective ||
|
||||
(path_flag & PATH_RAY_DIFFUSE) == 0);
|
||||
const bool glass_caustics = (kernel_data.integrator.caustics_reflective ||
|
||||
kernel_data.integrator.caustics_refractive ||
|
||||
(path_flag & PATH_RAY_DIFFUSE) == 0);
|
||||
const bool refractive_caustics = (kernel_data.integrator.caustics_refractive ||
|
||||
(path_flag & PATH_RAY_DIFFUSE) == 0);
|
||||
#else
|
||||
const bool reflective_caustics = true;
|
||||
const bool glass_caustics = true;
|
||||
const bool refractive_caustics = true;
|
||||
#endif
|
||||
|
||||
/* Before any actual shader components, apply transparency. */
|
||||
|
@ -302,7 +301,7 @@ ccl_device
|
|||
|
||||
/* Transmission component */
|
||||
if (transmission_weight > CLOSURE_WEIGHT_CUTOFF) {
|
||||
if (glass_caustics) {
|
||||
if (reflective_caustics || refractive_caustics) {
|
||||
ccl_private MicrofacetBsdf *bsdf = (ccl_private MicrofacetBsdf *)bsdf_alloc(
|
||||
sd, sizeof(MicrofacetBsdf), transmission_weight * weight);
|
||||
ccl_private FresnelGeneralizedSchlick *fresnel =
|
||||
|
@ -320,8 +319,10 @@ ccl_device
|
|||
fresnel->f0 = make_float3(F0_from_ior(ior)) * specular_tint;
|
||||
fresnel->f90 = one_spectrum();
|
||||
fresnel->exponent = -ior;
|
||||
fresnel->reflection_tint = one_spectrum();
|
||||
fresnel->transmission_tint = sqrt(rgb_to_spectrum(clamped_base_color));
|
||||
fresnel->reflection_tint = reflective_caustics ? one_spectrum() : zero_spectrum();
|
||||
fresnel->transmission_tint = refractive_caustics ?
|
||||
sqrt(rgb_to_spectrum(clamped_base_color)) :
|
||||
zero_spectrum();
|
||||
|
||||
/* setup bsdf */
|
||||
sd->flag |= bsdf_microfacet_ggx_glass_setup(bsdf);
|
||||
|
@ -556,9 +557,15 @@ ccl_device
|
|||
case CLOSURE_BSDF_MICROFACET_BECKMANN_GLASS_ID:
|
||||
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID: {
|
||||
#ifdef __CAUSTICS_TRICKS__
|
||||
if (!kernel_data.integrator.caustics_reflective &&
|
||||
!kernel_data.integrator.caustics_refractive && (path_flag & PATH_RAY_DIFFUSE))
|
||||
const bool reflective_caustics = (kernel_data.integrator.caustics_reflective ||
|
||||
(path_flag & PATH_RAY_DIFFUSE) == 0);
|
||||
const bool refractive_caustics = (kernel_data.integrator.caustics_refractive ||
|
||||
(path_flag & PATH_RAY_DIFFUSE) == 0);
|
||||
if (!(reflective_caustics || refractive_caustics))
|
||||
break;
|
||||
#else
|
||||
const bool reflective_caustics = true;
|
||||
const bool refractive_caustics = true;
|
||||
#endif
|
||||
ccl_private MicrofacetBsdf *bsdf = (ccl_private MicrofacetBsdf *)bsdf_alloc(
|
||||
sd, sizeof(MicrofacetBsdf), make_spectrum(mix_weight));
|
||||
|
@ -579,8 +586,9 @@ ccl_device
|
|||
fresnel->f90 = one_spectrum();
|
||||
fresnel->exponent = -ior;
|
||||
const float3 color = stack_load_float3(stack, data_node.z);
|
||||
fresnel->reflection_tint = color;
|
||||
fresnel->transmission_tint = color;
|
||||
fresnel->reflection_tint = reflective_caustics ? rgb_to_spectrum(color) : zero_spectrum();
|
||||
fresnel->transmission_tint = refractive_caustics ? rgb_to_spectrum(color) :
|
||||
zero_spectrum();
|
||||
|
||||
/* setup bsdf */
|
||||
if (type == CLOSURE_BSDF_MICROFACET_BECKMANN_GLASS_ID) {
|
||||
|
|
Loading…
Reference in New Issue