Thanks for looking into this
And for reminding me to look into the VEX code!
I downloaded your scene with the fix and it works for me with principle and classic shader
But I had to fix something in the code
I got an error in the render view:
Reference to undefined variable: u (9, 24)I changed
float angle = asin(u*2-1);
to
float angle = asin($u*2-1);
and it worked
That said, it does not work with the pbrreflect1 though
I get a
Reference to undefined variable: I (1, 27)A problem with the first line:
vector $ii = normalize(I);
which I don't know how to fix
I tested your fix in Houdini 18.0.287. You?
About the line
if ($bow) $Nhair += ($u*2-1) * normalize(dPds);
Looks like $u is remaped from (0, 1) to (-1, 1) to then multiply dPds
dPds represents the tangent along the parametric coordinate u (let's call it tangentu)
So this lines adds 0*tangentu in the middle: you get N calculated before
And then progressively adds tangentu to N when getting to the edges
I am guessing this line is originally here to fake “rotate” the normal
But if so, then it should also reduce the N while getting to the edges, which this line does not
I think it should be something along:
$Nhair = (1-abs($u*2-1))*Nhair + ($u*2-1) * normalize(dPds);
With this code I get something close to your solution, but not exactly the same
And close to the polywire version, but not exactly the same either!
vector $ii = normalize(I);
vector $ht = normalize(dPdt);
float $u = s;
VOPvector $orth = cross(ht, -ii);
VOPnormal $Nhair = cross(ht, orth);
Nhair = normalize(frontface(Nhair, ii));
Nhair = (1-abs($u*2-1))*normalize(Nhair) + ($u*2-1) * normalize(dPds);
$hairNn = normalize(Nhair);
Your solution, with matrices, seems more academic though
I will submit that to support as a bug/RFE