[Bf-blender-cvs] [cc8dce80ae2] principled-v2: Use refracted angle for clearcoat tint calculation to fix extreme saturation
Lukas Stockner
noreply at git.blender.org
Mon Jul 4 23:56:16 CEST 2022
Commit: cc8dce80ae2bf3cf651f4b887a3c52e904b48196
Author: Lukas Stockner
Date: Mon Jul 4 23:31:48 2022 +0200
Branches: principled-v2
https://developer.blender.org/rBcc8dce80ae2bf3cf651f4b887a3c52e904b48196
Use refracted angle for clearcoat tint calculation to fix extreme saturation
===================================================================
M intern/cycles/kernel/svm/closure_principled.h
===================================================================
diff --git a/intern/cycles/kernel/svm/closure_principled.h b/intern/cycles/kernel/svm/closure_principled.h
index 1966b06fe0c..7260ed416b7 100644
--- a/intern/cycles/kernel/svm/closure_principled.h
+++ b/intern/cycles/kernel/svm/closure_principled.h
@@ -501,7 +501,10 @@ ccl_device_inline float3 principled_v2_clearcoat(KernelGlobals kg,
* That way, mirrors preserve their look, but diffuse-ish objects have a more natural behavior.
*/
float cosNI = dot(sd->I, N);
- float optical_depth = 1.0f / cosNI;
+ /* Refract incoming direction into clearcoat material, which has a fixed IOR of 1.5.
+ * TIR is no concern here since we're always coming from the outside. */
+ float cosNT = sqrtf(1.0f - sqr(1.0f / 1.5f) * (1 - sqr(cosNI)));
+ float optical_depth = 1.0f / cosNT;
tint = pow(tint, optical_depth * clearcoat);
}
@@ -659,7 +662,8 @@ ccl_device void svm_node_closure_principled_v2(KernelGlobals kg,
uint base_color_offset, normal_offset, dummy;
uint roughness_offset, metallic_offset, ior_offset, transmission_offset;
svm_unpack_node_uchar4(node_1.y, &dummy, &base_color_offset, &normal_offset, &dummy);
- svm_unpack_node_uchar4(node_1.z, &roughness_offset, &metallic_offset, &ior_offset, &transmission_offset);
+ svm_unpack_node_uchar4(
+ node_1.z, &roughness_offset, &metallic_offset, &ior_offset, &transmission_offset);
float3 base_color = stack_load_float3(stack, base_color_offset);
float3 N = stack_valid(normal_offset) ? stack_load_float3(stack, normal_offset) : sd->N;
More information about the Bf-blender-cvs
mailing list