Jump to content

Hair revisited


Marc

Recommended Posts

  • 1 month later...

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

Link to comment
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) {
	  shadow(Cl);				   // run the shadow shader, if any
	  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.

Link to comment
Share on other sites

  • 1 month later...
  • 11 months later...

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.

Link to comment
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...

Link to comment
Share on other sites

  • 1 year later...
  • 9 months later...

Hi!

I've downloaded the arno hair shader. And I see in the scene that the code of this shader is only "#include "arno_hair_far_field_circular_v_1_9.vfl"".

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

Thank you :)

Link to comment
Share on other sites

Hi!

I've downloaded the arno hair shader. And I see in the scene that the code of this shader is only "#include "arno_hair_far_field_circular_v_1_9.vfl"".

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.
Link to comment
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.

Link to comment
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

Link to comment
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

...

}

Link to comment
Share on other sites

Thank you Symek! :D

No problem, I love to copy/pasting things around :D

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...