# Hair revisited

## Recommended Posts

Sample:

Fur.mpg

Edited by Wolfwood

##### Share on other sites

Hey everyone!

I have a question: How do you guys write shaders?

I'm looking through a few of the papers mentioned in this thread, and I'm looking at bfx's mention of Dan B Goldman's "Fake Fur Rendering", as well as Kajiya and Kay's paper, Rendering Fur with Three Dimensional Textures.

For example, we have from Dan's paper (which seems to be the kajiya and kay shading model),

Diffuse = Kd * sin(T,L)

Spec = Ks * pow( (T.L * T.E + sin(T,L)* sin(T,E)), phong)

So, should the Diffuse contribution simply be Kd multiplied by the sin of the angle between the tangent vector and light vector?

i.e. in VEX:

float Kd = 1; (should be variable in the shader's function header)

vector T = normalize(dPdt);

vector Diff = 0;

illuminance(P,N,PI)

{

vector nL = normalize(L);

Diff += Kd * sin( acos( dot(T, nL) ) );

}

Cf = Diff;

Is this the correct way to interprete the formulas?

JT

##### Share on other sites
Is this the correct way to interprete the formulas?

Hi there,

I don't know that paper, but as far as translating those two formulas into VEX, I'd say it looks OK -- except that maybe you could simplify sin(acos(x)) into sqrt(1-x^2). Also, you can safely pull the constants Kd and Ks out of the summation... and maybe call shadow() in case there's a shadow shader attached....

Here's a sketch with some of those extra details:

```#pragma label Ka	 "Ambient Amplitude"
#pragma label Kd	 "Diffuse Amplitude"
#pragma label Ks	 "Specular Amplitude"
#pragma label rough  "Specular Roughness"

surface simplehair (
float  Ka	= 1;	 // ambient amplitude
float  Kd	= 1;	 // diffuse amplitude
float  Ks	= 1;	 // specular amplitude
float  rough = 0.05;  // specular roughness

vector Cd	= 1;	 // "hidden" surface color
// sometimes bound to geo
)
{
vector T  = normalize(dPdt);
vector E  = normalize(-I);
float  TE = dot(T,E);

vector Cdiff = 0, Cspec = 0;
illuminance(P,N,M_PI) {
vector nL = normalize(L);
float  TL = dot(T,nL);
float  sTL = sqrt(1.0-TL*TL); // sin(T.L)
Cdiff += Cl * sTL;
Cspec += Cl * pow(TL*TE + sTL*sqrt(1.0-TE*TE),1.0/rough);
}

Cf = Cd * (Ka*ambient() + Kd*Cdiff) + Ks*Cspec;
}```

HTH.

P.S: I just took a quick peek at Dan's paper, and those two formulas are just the begining... he then spends the rest of the paper developing a heap'o'stuff to compensate for what's missing in that simple model... just thought I'd mention it.

##### Share on other sites

check it

Edited by horizon1231

##### Share on other sites

For reference, you could always consult the VEX Hair SHOP that comes with Houdini.

##### Share on other sites

No. That thing I posted at the beginning of this thread wasn't a shader; it was a vop that calculated the tube normal of an RiCurve (or open poly line in houdini-speak)... not even remotely in the neighborhood of something that could be called a shader. The work that both Arno Zinke and Mark Visser have done is light years ahead of any hair-related thing I've posted anywhere at odForce.

I'd suggest you either use the shader that comes with Mark's Fuzzy Toolkit, or the one that's bundled with H9.5. (and possibly the encrypted version that Arno posted elsewhere in his hair thread if it still works with the current Mantra versions).

And no; none of the above are supplied in the form of vex code that you can tinker with... think about it.

Cheers.

##### Share on other sites

The one that comes with Mark's Fuzzy Toolkit is compiled version and seems to work only with 9.1. Btw where can i find that shader. I thought to use Kajiya Kay model but Marks Fuzzy looks interesting.....

The reason why im asking this is that I want to generate fur in Rendertime... with output per lights and passes like Pbowmar example of exporting per lights. If I have vex code or vop for it then it will be easy for me to tweak and integrate with the new Cvex to get the desired output...

##### Share on other sites

Ive just checked out the shader code and found that its the Kajiya kay model which is giving nice looking fur and giving the output and the quality that Ive expected...

Edited by kensonuken

##### Share on other sites

Hi!

I understeand that this shader is compiled without source code? I'm right?

Thank you

##### Share on other sites

Hi!

I understeand that this shader is compiled without source code? I'm right?

Thank you

And no; none of the above are supplied in the form of vex code that you can tinker with... think about it.

##### Share on other sites

To boot: the far field shaders are famously slow, unpredictable and unstable-- and kinda unavailable

If I were you, I'd use kajiya plus two specular terms of your own, a simple hack gain a similar effect to the double specular the Marschener shader gives you.

##### Share on other sites

Does anyone know what model the current Houdini hair shader is using? I'm always intrigued by these discussions when it seems like the built in shader does a pretty good job out the box.

M

##### Share on other sites

Does anyone know what model the current Houdini hair shader is using? I'm always intrigued by these discussions when it seems like the built in shader does a pretty good job out the box.

M

vector

vop_hairspec(vector nn, V, T; float exp;)

{

// Specular illumination model from:

// James T. Kajiya and Timothy L. Kay (1989) "Rendering Fur with Three

// Dimensional Textures", Computer Graphics 23,3, 271-280

...

}

##### Share on other sites

ah yeah.... um... I knew that, of course.

Thanks SYmek!

##### Share on other sites

No problem, I love to copy/pasting things around

##### Share on other sites

Thank you Symek!

No problem, I love to copy/pasting things around

Symek could you please tell me where have you found this info?

When I'm looking into shaders in houdini I can see 2 materials (with vop vex surface shaders - but they have no comments) and a "Vex Hair" shader, which is not this one, what you're talking about. Am I right?

Edited by danilo2

##### Share on other sites

\$HFS/houdini/vex/include/voplib.h. The ultimate vops' handbook.

##### Share on other sites

\$HFS/houdini/vex/include/voplib.h. The ultimate vops' handbook.

Ahh of course!

## Create an account

Register a new account