Jump to content

Houdini Fur shader mod to Kajiya Kay


kensonuken

Recommended Posts

I was just checking the code of Houdini Fur shader which was not kajiya kay... Is there any possibility where we can use kajiya kay shader in Houdini? or can we modify the current kajiya kay shader to Houdini shader?

here is the prman code that I have .

/////////////////////////////

////////////////////////////////////////////////////////////////////////////////

// based on ATI's paper 'Hair Rendering and Shading', by Thorsten Scheuermann //

// 3D application research group, ATI research Inc. ////////////////////////////

// this is a hair rendering technique originally made for polygon hair models //

// a mix of Kajiya-Kay hair shader model, and Marscher's model, presented at //

// Siggraph2003 ////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////

// shifting specular highlights along lenght of hair

vector shifttangent(

vector Tn;

normal Nf;

float shift;

)

{

vector shiftedt = Tn + shift * Nf;

return normalize(shiftedt);

}

/* Specular strand lighting */

float strandspecular(

vector Tn, Vn, Ln;

float exponent;

)

{

vector Hn = normalize(Ln + Vn);

float dotth = Tn.Hn;

float sinth = max( 0.0, sqrt( 1.0 - dotth * dotth ) );

float diratten = smoothstep(-1.0, 0.0, dotth);

return diratten * pow( sinth, exponent);

}

/* Main */

surface tshair(

//color tshair(

float Ka, Kd, Ks; //ambient, diffuse, specular coefficients

float shift; // primary specular highlight shift

float shift2; // secondary specular highlight shift

float exponent; // primary specular exponent

float exponent2; // secondary specular exponenet

float specmask; // specular mask, to shift secondary spec

color Cdiff; // surface color,sometimes bound to geo

color Cbase; // hair base color

color Ctip; // hair tip color

color Cspec; // primary specular color

color Cspec2; // secondary specular color

normal Nn; // normal vector

vector Vf; // viewer vector

)

{

/* We're going to need dPdv for direction, P for the illuminance

* construct, and the v coordinate for the color blend in the color

* contribution. */

extern vector dPdv;

extern point P;

extern float v;

vector T = normalize(dPdv);

normal Nf = faceforward( Nn, Vf );

vector t1 = shifttangent( T, Nf, shift - .5);

vector t2 = shifttangent( T, Nf, shift2 - .5);

float dottin = T.Vf;

color Cdd = 0;

color Css = 0;

illuminance( P, Nf, PI/2 )

{

extern vector L;

extern color Cl;

vector Ln = normalize(L);

uniform float nondiff = 0;

lightsource("__nondiffuse", nondiff);

if (nondiff < 1) {

/* Scaled diffuse term. Note that in the paper they use

* ambient occlusion to fake the hair shadowing. */

Cdd = clamp( mix( .25, 1.0, Nf.Ln), 0, 1);

}

uniform float nonspec = 0;

lightsource("__nonspecular", nonspec);

if (nonspec < 1) {

/* Primary specular */

Css = Cspec * (1-nonspec) * strandspecular( t1, Vf, Ln, exponent);

/* Secondary specular */

Css += Cspec2 * (1-nonspec) * specmask *

strandspecular( t2, Vf, Ln, exponent2);

}

}

return Cdd * mix( Cbase, Ctip, v) * (Ka*ambient() + Kd * Cdd ) +

Ks * Css;

}

I want to use this shader in Mantra... any possibility?

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...