surface
spd (float Ka = 1;
     float Kd = .5;
     float Ks = .5;
     float roughness = .1;
     color specularcolor = 1;
     float reflected = 0.;
     float transmitted = 0.;
     float index = 1.0;)
{
  normal Nn = faceforward (normalize(N),I);
  normal In = normalize( I );
  color r,tr;
     
      if (reflected > .001) {
   r = reflected * color trace (P, reflect(I, Nn));
      }
      if (transmitted > .001) {
   vector T = refract(In, Nn, (N.I)>0 ? index : 1/index ); 
   if ( length( T ) != 0.0 )
   tr = transmitted * color trace (P, T);
  }
     
  Oi = Os;
  Ci = Os * ( Cs * ( Kd*diffuse(Nn) + r + tr) +
       specularcolor * Ks*specular(Nn,-In,roughness));
}