[Bf-blender-cvs] [e73d4734f93] microfacet_hair: Switch normal and binormal if aspect ratio larger than 1

Weizhen Huang noreply at git.blender.org
Thu Dec 22 18:36:00 CET 2022


Commit: e73d4734f938722c352be1ba89ce06349e3c24e8
Author: Weizhen Huang
Date:   Thu Dec 22 18:32:40 2022 +0100
Branches: microfacet_hair
https://developer.blender.org/rBe73d4734f938722c352be1ba89ce06349e3c24e8

Switch normal and binormal if aspect ratio larger than 1

===================================================================

M	intern/cycles/kernel/svm/closure.h

===================================================================

diff --git a/intern/cycles/kernel/svm/closure.h b/intern/cycles/kernel/svm/closure.h
index a9a20b6ad7c..8406b81b30a 100644
--- a/intern/cycles/kernel/svm/closure.h
+++ b/intern/cycles/kernel/svm/closure.h
@@ -1023,12 +1023,20 @@ ccl_device_noinline int svm_node_closure_bsdf(KernelGlobals kg,
           float eccentricity = stack_load_float_default(stack, eccentricity_ofs, data_node5.y);
 
           /* Eccentricity */
-          bsdf->extra->eccentricity = (eccentricity > 1.f) ? 1.f / eccentricity : eccentricity;
+          bsdf->extra->eccentricity = (eccentricity > 1.0f) ? 1.0f / eccentricity : eccentricity;
 
           const AttributeDescriptor attr_descr_normal = find_attribute(kg, sd, data_node5.z);
           const float3 normal = curve_attribute_float3(kg, sd, attr_descr_normal, NULL, NULL);
           const float3 binormal = safe_normalize(cross(sd->dPdu, normal));
-          bsdf->extra->geom = make_float4(binormal.x, binormal.y, binormal.z, 0.0f);
+
+          /* Align X axis with the ellipse major axis. */
+          if (eccentricity > 1.0f) {
+            const float3 normal = safe_normalize(cross(binormal, sd->dPdu));
+            bsdf->extra->geom = make_float4(normal.x, normal.y, normal.z, 0.0f);
+          }
+          else {
+            bsdf->extra->geom = make_float4(binormal.x, binormal.y, binormal.z, 0.0f);
+          }
         }
 
         sd->flag |= bsdf_microfacet_hair_setup(sd, bsdf);



More information about the Bf-blender-cvs mailing list