Maya Shaders

Wednesday, September 28, 2005

Stripes


The Stripes function.

This node implicitly gets (x,y,z) coordinates from Maya API and calculates , together with Noise as its randomness, draws a stripey effect on its surfaces.

The stripes are basically a sinsusoidal function with a hashed input of "turbulence" and octaves.

//turbulence function
double noise3::turbulence(double x, double y, double z, double octaves)
{
double turb = -0.5;
double s = 1.00;
while (octaves--)
{
turb+=pnoise3((float)x,(float)y,(float)z) *s ;
s*= 0.5 ; x*=1.5; y*=1.5; z*=1.5;
}
return turb;
}

//stripes function
double noise3::stripes(double x, double f)
{
double t = 0.5 + 0.5 * sin(f * 2 * M_PI * x);
return t * t - 0.5;
}

//the final implementation
float val = 0.5 * stripes( worldPos[0]+ 2 * float(turbulence(worldPos[0],worldPos[1],worldPos[2],1)), 0.3);

0 Comments:

Post a Comment

<< Home