/* William Schilthuis WilliamGS.com http://www.sfdm.scad.edu/faculty/mkesson/vsfx319/index.html spring 2009 Renderman Archive ST Coloration "Biohazard Symbol" This surface defines a complex pattern with IF statements, but calculates diffuse and specular lighting, allows for manipulation of the pattern including loading a background image. */ surface wgs_biohazard03( float Kd = 0.7; /* [0 1] Diffuse Coefficient*/ float Ks = 0.8; /* [0 1] Specular Coefficient*/ float roughness = 0.1; /* [0 1] Specular Spread*/ color highlightcolor = (1.0,0.95,0.8); /* Specular Color*/ string textr = ""; /* Background Image*/ float trxbg = 0.0; /* [0 1] transparency background */ color cola = color (0.0,0.0,0.0); /* BG color */ color colb = color (0.9,0.1,0.1); /* outer circles */ color colc = color (0.1,0.9,0.1); /* inner circle */ color cold = color (0.1,0.1,0.9); /* inner circle */ float c1ct = 3; /* [0 16 1] circle1 count */ float c1r = 0.18; /* [0.0 0.5] circle1 radius */ float c1t = 0.2; /* [0 1] circle1 tangent */ float c1o = 0.0; /* [-3.14159 3.14159] circle1 radial offset */ float cio = 0.02;/* circle inner offset */ float c2ct = 3; /* [0 16 1] circle2 count */ float c2r = 0.12; /* [0.0 0.5] circle1 radius */ float c2t = 0.24; /* [0 1] circle2 tangent */ float c2o = 0; /* [-3.14159 3.14159] circle2 radial offset */ ) { color surfcolor = cola; //set initial surface color Oi = Os * trxbg; //set initial surface opacity if(textr != "") surfcolor = texture(textr, s, 1 -t); else surfcolor = cola; normal n = normalize(N); normal nf = faceforward( n, I); float c1d = (1/c1ct)*2*PI; //circle1 theta (radial distribution) float c2d = (1/c2ct)*2*PI; //circle1 theta (radial distribution) float j; //define local count variable // Outer Circles. for (j = 0; j < c1ct; j += 1) { if( ((s-(0.5+sin(c1d*j)*c1t)) *(s-(0.5+sin(c1d*j)*c1t)))+ ((t-(0.5+cos(c1d*j)*c1t)) *(t-(0.5+cos(c1d*j)*c1t))) < c1r*0.25 && ((s-(0.5+sin(c2d*j+c2o)*c2t)) *(s-(0.5+sin(c2d*j+c2o)*c2t)))+ ((t-(0.5+cos(c2d*j+c2o)*c2t)) *(t-(0.5+cos(c2d*j+c2o)*c2t))) > c2r*0.25 && ((s-0.5)*(s-0.5))+((t-0.5)*(t-0.5)) > c1r*0.01 ) surfcolor = colb; if( ((s-(0.5+sin(c1d*j)*c1t)) *(s-(0.5+sin(c1d*j)*c1t)))+ ((t-(0.5+cos(c1d*j)*c1t)) *(t-(0.5+cos(c1d*j)*c1t))) < c1r*0.25 && ((s-(0.5+sin(c2d*j+c2o)*c2t)) *(s-(0.5+sin(c2d*j+c2o)*c2t)))+ ((t-(0.5+cos(c2d*j+c2o)*c2t)) *(t-(0.5+cos(c2d*j+c2o)*c2t))) > c2r*0.25 && ((s-0.5)*(s-0.5))+((t-0.5)*(t-0.5)) > c1r*0.01 ) Oi = Os; } // Inner division lines for (j = 0; j < c1ct; j += 1) { if( ((s-(0.5+sin(c1d*j+PI)*(c1t+cio))) *(s-(0.5+sin(c1d*j+PI)*(c1t+cio))))+//bottom edge ((t-(0.5+cos(c1d*j+PI)*(c1t+cio))) *(t-(0.5+cos(c1d*j+PI)*(c1t+cio)))) //bottom edge < c1r*0.25 && ((s-(0.5+sin(c1d*j+PI)*(c1t+cio*2))) *(s-(0.5+sin(c1d*j+PI)*(c1t+cio*2))))+//top edge ((t-(0.5+cos(c1d*j+PI)*(c1t+cio*2))) *(t-(0.5+cos(c1d*j+PI)*(c1t+cio*2)))) //top edge > c1r*0.25 ) surfcolor = cola; if( ((s-(0.5+sin(c1d*j+PI)*(c1t+cio))) *(s-(0.5+sin(c1d*j+PI)*(c1t+cio))))+//bottom edge ((t-(0.5+cos(c1d*j+PI)*(c1t+cio))) *(t-(0.5+cos(c1d*j+PI)*(c1t+cio)))) //bottom edge < c1r*0.25 && ((s-(0.5+sin(c1d*j+PI)*(c1t+cio*2))) *(s-(0.5+sin(c1d*j+PI)*(c1t+cio*2))))+//top edge ((t-(0.5+cos(c1d*j+PI)*(c1t+cio*2))) *(t-(0.5+cos(c1d*j+PI)*(c1t+cio*2)))) //top edge > c1r*0.25 ) Oi = Os * trxbg; } // Inner Circle. for (j = 0; j < c1ct; j += 1) { if( ((s-0.5)*(s-0.5))+((t-0.5)*(t-0.5)) < c1r*0.20 && ((s-0.5)*(s-0.5))+((t-0.5)*(t-0.5)) > c2r*0.15 && ((s-(0.5+sin(c2d*j+c2o)*c2t)) *(s-(0.5+sin(c2d*j+c2o)*c2t)))+ ((t-(0.5+cos(c2d*j+c2o)*c2t)) *(t-(0.5+cos(c2d*j+c2o)*c2t))) < c2r*0.20 ) surfcolor = colb; if( ((s-0.5)*(s-0.5))+((t-0.5)*(t-0.5)) < c1r*0.20 && ((s-0.5)*(s-0.5))+((t-0.5)*(t-0.5)) > c2r*0.15 && ((s-(0.5+sin(c2d*j+c2o)*c2t)) *(s-(0.5+sin(c2d*j+c2o)*c2t)))+ ((t-(0.5+cos(c2d*j+c2o)*c2t)) *(t-(0.5+cos(c2d*j+c2o)*c2t))) < c2r*0.20 ) Oi = Os; } /* calculate the apparent surface color */ color diffusecolor = diffuse(nf) * Kd; vector i = normalize(-I); color speccolor = specular(nf, i, roughness) * highlightcolor * Ks; Ci = Oi * Cs * surfcolor * (diffusecolor + speccolor); }