slim 1 extensions ptakun { extensions fundza cutr { template normal ShaveNormal { templatehints vectors.slim description {No shader description available} parameter normal N_Srf { display hidden detail varying provider primitive default {0 0 0} } parameter float shaveNmulti { description "How much of Color 2 to mix with Color 1" label "Shave Normal" subtype slider range {0 1} detail varying default 1 } parameter float tubeNmulti { description "How much of Color 2 to mix with Color 1" label "Tube Normal" subtype slider range {0 1} detail varying default 0 } parameter float shadingNmulti { description "How much of Color 2 to mix with Color 1" label "Shading Normal" subtype slider range {0 1} detail varying default 0 } parameter float surfaceNmulti { description "How much of Color 2 to mix with Color 1" label "Surface Normal" subtype slider range {0 1} detail varying default 0 } parameter normal result { access output display hidden } RSLSource StaticFunction { void cutrShaveNormal( float shaveNmulti; float tubeNmulti; float shadingNmulti ; float surfaceNmulti; output normal result;) { extern normal N_Srf; //tanget normal vector tn = (dPdv); vector sn = (dPdu); vector Nt = -tn^sn; //cross tanget and surface normal vector Nsrf =normalize (N_Srf); vector Ss = Nsrf^tn; vector N_hair =normalize (tn^Ss); //tube normal normal Nf = faceforward( normalize(N), I ); normal Ntube = normalize( normal( rotate( point(Nf), (u-0.5 ) * PI, point(0), point(tn) ) ) ); result = normalize((N_hair*shaveNmulti)+(Ntube*tubeNmulti)+(N*shadingNmulti)+(N_Srf*surfaceNmulti)); } } } } }