/* * curlyball * * DESCRIPTION: * Fun sin() curve mixed with balls * * PARAMETERS: * Ka, Kd, Ks, roughness, specularcolor - work just like the plastic shader * wirecolor, ballcolor, wirewidth, repeat value * AUTHOR: Nick Meshes * * * * The RenderMan (R) Interface Procedures and RIB Protocol are: * Copyright 1988, 1989, Pixar. All rights reserved. * RenderMan (R) is a registered trademark of Pixar. */ surface curlyball( float Ka = 0.5, Kd = 0.4, Ks = 0.2; float roughness = 0.05; color specularcolor = 1; color wirecolor = color(0.937255, 0.447059, 0.752941); color ballcolor = color(0.643137, 0.180392, 0.87451); float wirewidth = 2.5; float repeat = 4; ) { float xpart = mod(xcomp(P), repeat); float ypart = mod(ycomp(P), repeat); float zpart = mod(zcomp(P), repeat); point thisp; setxcomp(thisp, xpart); setycomp(thisp, ypart); setzcomp(thisp, zpart); float besty = cos(xpart); float bestz = sin(xpart); point bestp; setxcomp(bestp, xpart); setycomp(bestp, besty); setzcomp(bestp, bestz); point distance = thisp - bestp; float len = length(distance); if (len < (wirewidth/2)){ Cs = wirecolor; Os = len/wirewidth; } point nextp; setxcomp(nextp, repeat/2); setycomp(nextp, repeat/2); setycomp(nextp, repeat/2); distance = thisp - nextp; len = length(distance); if (len < repeat){ Cs = ballcolor; Os = 1; } normal Nf = faceforward (normalize(N),I); Oi = Os; Ci = Os * ( Cs * (Ka*ambient() + Kd*diffuse(Nf)) + specularcolor * Ks*specular(Nf,-normalize(I),roughness)); }