Cycles: Speed up principled BSDF when IOR = 1.0

Skip the specular layer of the principled BSDF when IOR=1.0
since it has no visual impact on the material.

Pull Request: https://projects.blender.org/blender/blender/pulls/111586
This commit is contained in:
Brecht Van Lommel 2023-10-06 19:01:54 +02:00
parent 33cbe4c108
commit c1b4af86b9
2 changed files with 10 additions and 8 deletions

View File

@ -82,14 +82,16 @@ shader node_principled_bsdf(string distribution = "multi_ggx",
BSDF = mix(BSDF, BaseColor * SubsurfBSDF, subsurface_weight);
}
/* Apply specular tint */
color F0 = f0 * specular_tint;
color F90 = color(1.0);
if (eta != 1.0) {
/* Apply specular tint */
color F0 = f0 * specular_tint;
color F90 = color(1.0);
BSDF = layer(
generalized_schlick_bsdf(
Normal, T, color(1.0), color(0.0), alpha_x, alpha_y, F0, F90, -eta, distribution),
BSDF);
BSDF = layer(
generalized_schlick_bsdf(
Normal, T, color(1.0), color(0.0), alpha_x, alpha_y, F0, F90, -eta, distribution),
BSDF);
}
}
closure color TransmissionBSDF = 0;

View File

@ -339,7 +339,7 @@ ccl_device
}
/* Specular component */
if (reflective_caustics) {
if (reflective_caustics && eta != 1.0f) {
ccl_private MicrofacetBsdf *bsdf = (ccl_private MicrofacetBsdf *)bsdf_alloc(
sd, sizeof(MicrofacetBsdf), weight);
ccl_private FresnelGeneralizedSchlick *fresnel =