/* * xyz.sl - Solid texture to see where is what * (c) Copyright 1998, Denis P. Leconte, denis_leconte@geocities.com * * The RenderMan (R) Interface Procedures and RIB Protocol are: * Copyright 1988, 1989, Pixar. All rights reserved. * RenderMan (R) is a registered trademark of Pixar. * * Description: * Colors an object with a grid that follows either the world or * object coordinate system. * X-normal "grid slabs" are red * Y-normal "grid slabs" are green * Z-normal "grid slabs" are blue * The "softer" edge of a "grid slab" is towards the higher values * of the axis that slab is normal to. * * Parameters: * Ka, Kd: self-explanatory * what: 0 for world coordinates, 1 for object coordinates * gridsize: grid interval size * * 11/24/1998 Denis P. Leconte * Initial Version, from plastic.sl */ surface xyz ( float Ka = 1; float Kd = .5; float what= 0; float gridsize= 0.2; ) { point PP; color Yellow, Cyan, Magenta; float a, b, c; Cyan= (0, 1, 1); Magenta= (1, 0, 1); Yellow= (1, 1, 0); if (what == 0) PP= transform("world", P); /* World coordinates */ if (what == 1) PP= transform("object", P); /* Object coordinates */ Cs= (1, 1, 1); a= xcomp(PP) / gridsize; b= a - floor(a); c= 1 - smoothstep(0.1, 0.5, b); Cs -= Cyan * c; a= ycomp(PP) / gridsize; b= a - floor(a); c= 1 - smoothstep(0.1, 0.5, b); Cs -= Magenta * c; a= zcomp(PP) / gridsize; b= a - floor(a); c= 1 - smoothstep(0.1, 0.5, b); Cs -= Yellow * c; normal Nf = faceforward (normalize(N),I); Oi = Os; Ci = Os * Cs * (Ka*ambient() + Kd*diffuse(Nf)); }