/* stripe.sl (used for project II -------------------------*/ /* Name: Phuc Nguyen Danny Ho */ /* Login: cs184-dh cs184-dl */ /* SID: 13547274 */ /* ---------------------------------------------------------*/ /* --------------------------------------------------------- */ /* This is a surface shader that creates a cross curves on */ /* a surface */ /* filled circles. */ /* Parameters: */ /* bkgrdColor (RBG color) - Color of the background */ /* stripeColor (RBG color) - background color */ /* frequency (float) - indicates how many times the */ /* stripes repeated in a unit */ /* interval. */ /* */ /* roughness (float) - to adjust the brighness */ /* ----------------------------------------------------------*/ surface stripe( color bkgrdColor = color (0.8,0.7,0.7), stripeColor = color (0.8490, 0.2745, 0.2667); float Width = 0.3, sThickness = 0.03, frequency = 10, roughness = 0.6, Ka = 1, Kd = .5, Ks = .2 ) { float ss = mod(s*frequency,1), /* locations the point */ tt = mod(t*frequency,1), width = Width + sThickness; uniform float F = sThickness * 0.5 / width; point Nf = faceforward(normalize(N),I); point V = normalize(-I); /* the point is in the stripe zone */ if (tt < F) Ci = bkgrdColor; else if (tt > (1.0 - F)) Ci = stripeColor; if (ss < F) Ci = bkgrdColor; else if (ss > (1.0 - F)) Ci = stripeColor; /* the output of the point */ Oi = Os; Ci = Oi * Ci * (Ka * ambient() + Ks * specular(Nf,V, roughness) + Kd * diffuse(Nf)); }