Fix T51408: Cycles - Principled BSDF Shader - Transparency is not working as expected

Renamed the "Transparency" input of the Principled BSDF to
"Transmission" and "Refraction Roughness" to "Transmission Roughness".
This commit is contained in:
Pascal Schoen
2017-05-18 13:15:32 +02:00
parent 208462e424
commit 32c9d2322c
6 changed files with 43 additions and 43 deletions

View File

@@ -34,17 +34,17 @@ shader node_principled_bsdf(
float Clearcoat = 0.0,
float ClearcoatGloss = 1.0,
float IOR = 1.45,
float Transparency = 0.0,
float RefractionRoughness = 0.0,
float Transmission = 0.0,
float TransmissionRoughness = 0.0,
normal Normal = N,
normal ClearcoatNormal = N,
normal Tangent = normalize(dPdu),
output closure color BSDF = 0)
{
float f = max(IOR, 1e-5);
float diffuse_weight = (1.0 - clamp(Metallic, 0.0, 1.0)) * (1.0 - clamp(Transparency, 0.0, 1.0));
float transp = clamp(Transparency, 0.0, 1.0) * (1.0 - clamp(Metallic, 0.0, 1.0));
float specular_weight = (1.0 - transp);
float diffuse_weight = (1.0 - clamp(Metallic, 0.0, 1.0)) * (1.0 - clamp(Transmission, 0.0, 1.0));
float final_transmission = clamp(Transmission, 0.0, 1.0) * (1.0 - clamp(Metallic, 0.0, 1.0));
float specular_weight = (1.0 - final_transmission);
vector T = Tangent;
@@ -90,7 +90,7 @@ shader node_principled_bsdf(
}
}
if (transp > 1e-5) {
if (final_transmission > 1e-5) {
color Cspec0 = BaseColor * SpecularTint + color(1.0, 1.0, 1.0) * (1.0 - SpecularTint);
float eta = backfacing() ? 1.0 / f : f;
@@ -98,18 +98,18 @@ shader node_principled_bsdf(
float cosNO = dot(Normal, I);
float Fr = fresnel_dielectric_cos(cosNO, eta);
float refl_roughness = Roughness;
if (Roughness <= 1e-2)
refl_roughness = 0.0;
float refl_roughness = Roughness;
if (Roughness <= 1e-2)
refl_roughness = 0.0;
float refraction_roughness = refl_roughness;
float transmission_roughness = refl_roughness;
if (distribution == "GGX")
refraction_roughness = 1.0 - (1.0 - refl_roughness) * (1.0 - RefractionRoughness);
transmission_roughness = 1.0 - (1.0 - refl_roughness) * (1.0 - TransmissionRoughness);
BSDF = BSDF + transp * (Fr * microfacet_ggx_fresnel(Normal, refl_roughness * refl_roughness, eta, BaseColor, Cspec0) +
(1.0 - Fr) * BaseColor * microfacet_ggx_refraction(Normal, refraction_roughness * refraction_roughness, eta));
BSDF = BSDF + final_transmission * (Fr * microfacet_ggx_fresnel(Normal, refl_roughness * refl_roughness, eta, BaseColor, Cspec0) +
(1.0 - Fr) * BaseColor * microfacet_ggx_refraction(Normal, transmission_roughness * transmission_roughness, eta));
} else {
BSDF = BSDF + transp * microfacet_multi_ggx_glass_fresnel(Normal, Roughness * Roughness, eta, BaseColor, Cspec0);
BSDF = BSDF + final_transmission * microfacet_multi_ggx_glass_fresnel(Normal, Roughness * Roughness, eta, BaseColor, Cspec0);
}
}

View File

@@ -79,14 +79,14 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
#ifdef __PRINCIPLED__
case CLOSURE_BSDF_PRINCIPLED_ID: {
uint specular_offset, roughness_offset, specular_tint_offset, anisotropic_offset, sheen_offset,
sheen_tint_offset, clearcoat_offset, clearcoat_gloss_offset, eta_offset, transparency_offset,
anisotropic_rotation_offset, refraction_roughness_offset;
sheen_tint_offset, clearcoat_offset, clearcoat_gloss_offset, eta_offset, transmission_offset,
anisotropic_rotation_offset, transmission_roughness_offset;
uint4 data_node2 = read_node(kg, offset);
float3 T = stack_load_float3(stack, data_node.y);
decode_node_uchar4(data_node.z, &specular_offset, &roughness_offset, &specular_tint_offset, &anisotropic_offset);
decode_node_uchar4(data_node.w, &sheen_offset, &sheen_tint_offset, &clearcoat_offset, &clearcoat_gloss_offset);
decode_node_uchar4(data_node2.x, &eta_offset, &transparency_offset, &anisotropic_rotation_offset, &refraction_roughness_offset);
decode_node_uchar4(data_node2.x, &eta_offset, &transmission_offset, &anisotropic_rotation_offset, &transmission_roughness_offset);
// get Disney principled parameters
float metallic = param1;
@@ -99,9 +99,9 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
float sheen_tint = stack_load_float(stack, sheen_tint_offset);
float clearcoat = stack_load_float(stack, clearcoat_offset);
float clearcoat_gloss = stack_load_float(stack, clearcoat_gloss_offset);
float transparency = stack_load_float(stack, transparency_offset);
float transmission = stack_load_float(stack, transmission_offset);
float anisotropic_rotation = stack_load_float(stack, anisotropic_rotation_offset);
float refraction_roughness = stack_load_float(stack, refraction_roughness_offset);
float transmission_roughness = stack_load_float(stack, transmission_roughness_offset);
float eta = fmaxf(stack_load_float(stack, eta_offset), 1e-5f);
ClosureType distribution = stack_valid(data_node2.y) ? (ClosureType) data_node2.y : CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID;
@@ -118,10 +118,10 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
float fresnel = fresnel_dielectric_cos(cosNO, ior);
// calculate weights of the diffuse and specular part
float diffuse_weight = (1.0f - saturate(metallic)) * (1.0f - saturate(transparency));
float diffuse_weight = (1.0f - saturate(metallic)) * (1.0f - saturate(transmission));
float transp = saturate(transparency) * (1.0f - saturate(metallic));
float specular_weight = (1.0f - transp);
float final_transmission = saturate(transmission) * (1.0f - saturate(metallic));
float specular_weight = (1.0f - final_transmission);
// get the base color
uint4 data_base_color = read_node(kg, offset);
@@ -300,8 +300,8 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
#ifdef __CAUSTICS_TRICKS__
if(kernel_data.integrator.caustics_reflective || kernel_data.integrator.caustics_refractive || (path_flag & PATH_RAY_DIFFUSE) == 0) {
#endif
if(transp > CLOSURE_WEIGHT_CUTOFF) {
float3 glass_weight = weight * transp;
if(final_transmission > CLOSURE_WEIGHT_CUTOFF) {
float3 glass_weight = weight * final_transmission;
float3 cspec0 = base_color * specular_tint + make_float3(1.0f, 1.0f, 1.0f) * (1.0f - specular_tint);
if(roughness <= 5e-2f || distribution == CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID) { /* use single-scatter GGX */
@@ -342,12 +342,12 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
bsdf->N = N;
if(distribution == CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID)
refraction_roughness = 1.0f - (1.0f - refl_roughness) * (1.0f - refraction_roughness);
transmission_roughness = 1.0f - (1.0f - refl_roughness) * (1.0f - transmission_roughness);
else
refraction_roughness = refl_roughness;
transmission_roughness = refl_roughness;
bsdf->alpha_x = refraction_roughness * refraction_roughness;
bsdf->alpha_y = refraction_roughness * refraction_roughness;
bsdf->alpha_x = transmission_roughness * transmission_roughness;
bsdf->alpha_y = transmission_roughness * transmission_roughness;
bsdf->ior = ior;
/* setup bsdf */