From db65a6e0fb1c1294ab4a6141293416c9d57fb108 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 20 Mar 2020 15:22:29 +0100 Subject: Fix T74345: missing albedo for Cycles principled hair BSDF --- .../cycles/kernel/closure/bsdf_hair_principled.h | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'intern/cycles/kernel/closure') diff --git a/intern/cycles/kernel/closure/bsdf_hair_principled.h b/intern/cycles/kernel/closure/bsdf_hair_principled.h index 4db5a6cc830..f78bbeb5d9d 100644 --- a/intern/cycles/kernel/closure/bsdf_hair_principled.h +++ b/intern/cycles/kernel/closure/bsdf_hair_principled.h @@ -493,6 +493,36 @@ ccl_device void bsdf_principled_hair_blur(ShaderClosure *sc, float roughness) bsdf->m0_roughness = fmaxf(roughness, bsdf->m0_roughness); } +/* Hair Albedo */ + +ccl_device_inline float bsdf_principled_hair_albedo_roughness_scale( + const float azimuthal_roughness) +{ + const float x = azimuthal_roughness; + return (((((0.245f * x) + 5.574f) * x - 10.73f) * x + 2.532f) * x - 0.215f) * x + 5.969f; +} + +ccl_device float3 bsdf_principled_hair_albedo(ShaderClosure *sc) +{ + PrincipledHairBSDF *bsdf = (PrincipledHairBSDF *)sc; + return exp3(-sqrt(bsdf->sigma) * bsdf_principled_hair_albedo_roughness_scale(bsdf->v)); +} + +ccl_device_inline float3 +bsdf_principled_hair_sigma_from_reflectance(const float3 color, const float azimuthal_roughness) +{ + const float3 sigma = log3(color) / + bsdf_principled_hair_albedo_roughness_scale(azimuthal_roughness); + return sigma * sigma; +} + +ccl_device_inline float3 bsdf_principled_hair_sigma_from_concentration(const float eumelanin, + const float pheomelanin) +{ + return eumelanin * make_float3(0.506f, 0.841f, 1.653f) + + pheomelanin * make_float3(0.343f, 0.733f, 1.924f); +} + CCL_NAMESPACE_END #endif /* __BSDF_HAIR_PRINCIPLED_H__ */ -- cgit v1.2.3