Render Curve as Tube with Shader.
16703 10 3- Jack.N
- Member
- 72 posts
- Joined: March 2014
- Offline
- PradeepBarua
- Member
- 443 posts
- Joined: Sept. 2012
- Offline
- Jack.N
- Member
- 72 posts
- Joined: March 2014
- Offline
PradeepBarua
You can create “width” attribute on curve, mantra reads it.
Yes , I Knooooooooooooooow that :!:
the width attribute is only useful for thickness of the curve when rendering !
BUT, I wanna Render Curves as Tube , Not just simple FLAT curve and I wanna do that in rendering , not with polywire SOP !!!!
I know we can do that with N and displacement (and maybe frontface) , But I can't remember that :!:
- papi
- Member
- 37 posts
- Joined: Sept. 2010
- Offline
- tamte
- Member
- 8832 posts
- Joined: July 2007
- Offline
- Jack.N
- Member
- 72 posts
- Joined: March 2014
- Offline
- wlvl
- Member
- 23 posts
- Joined: July 2015
- Offline
tamte
you can just plug Hair Normal VOP to N of Surface Model
make sure Do Rounding is on
Hi Tomas,
I am using this method works perfectly.
but it makes my extra image passes disappear.
I am binding export some attributes inside the shader. The stop working if I plug in the hairnormal.
Any tips please?
Thanks!
- wlvl
- Member
- 23 posts
- Joined: July 2015
- Offline
- bebe
- Member
- 53 posts
- Joined: June 2009
- Offline
Hi,
I am following up on this old post about curve rendering as I have a related question.
I rendered a curve with this method (HairNormal plugged into a pianolacquer shader) and a polywired version of the same curve (with the default pianolacquer shader)
And there is a difference in the two renders, the rim light is not present on the curve with HairNormal shader, and the specs are quite different as well.
See renders and hip file attached.
Is there anything I am missing here, or is this the closest I can get to the polywired version?
I was hopping both renders would be the same
Thanks for your help
I am following up on this old post about curve rendering as I have a related question.
I rendered a curve with this method (HairNormal plugged into a pianolacquer shader) and a polywired version of the same curve (with the default pianolacquer shader)
And there is a difference in the two renders, the rim light is not present on the curve with HairNormal shader, and the specs are quite different as well.
See renders and hip file attached.
Is there anything I am missing here, or is this the closest I can get to the polywired version?
I was hopping both renders would be the same
Thanks for your help
- JH_Engelhardt
- Member
- 1 posts
- Joined: April 2016
- Offline
The same issue with visually varying results occurred to me at work today. Especially for light coming from the back.
I took the code from the hairnormal node and modified it, wich worked as a fix for me.
My math knowledge is not deep enough to understand this line:
“if ($bow) $Nhair += ($u*2-1) * normalize(dPds);”
Can anyone explain?
Instead of adding to the normal, I rotated it around the tangent:
“
float angle = asin(u*2-1);
matrix rot = ident();
vector axis = $ht;
rotate(rot, angle , axis);
vector rotateNn = $Nhair * rot;
”
The result is visually very close to the polywire version. But somehow does not work with classic-shader/principled-shader, as the normal is clamped on the edges (why?). It works with the basic pbr-components though.
Buil my workaround into bebe´s file.
I took the code from the hairnormal node and modified it, wich worked as a fix for me.
My math knowledge is not deep enough to understand this line:
“if ($bow) $Nhair += ($u*2-1) * normalize(dPds);”
Can anyone explain?
Instead of adding to the normal, I rotated it around the tangent:
“
float angle = asin(u*2-1);
matrix rot = ident();
vector axis = $ht;
rotate(rot, angle , axis);
vector rotateNn = $Nhair * rot;
”
The result is visually very close to the polywire version. But somehow does not work with classic-shader/principled-shader, as the normal is clamped on the edges (why?). It works with the basic pbr-components though.
Buil my workaround into bebe´s file.
- bebe
- Member
- 53 posts
- Joined: June 2009
- Offline
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 changedto 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:which I don't know how to fix
I tested your fix in Houdini 18.0.287. You?
About the lineLooks 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:
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!
Your solution, with matrices, seems more academic though
I will submit that to support as a bug/RFE
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);
float angle = asin($u*2-1);
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);
I tested your fix in Houdini 18.0.287. You?
About the line
if ($bow) $Nhair += ($u*2-1) * normalize(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
-
- Quick Links