/* surface shader: brick_shiny_building creator: Nick Meshes, DePaul University description: Based on loosely screen.sl and shiny.sl Makes a surface that looks like an office building with reflective windows. Walls look plastic-like though. parameters: Ka, Kd, Ks, roughness, specularcolor - work just like the plastic shader wallcolor and windowcolor window width and height set parts between windows set as well. up - x=0, y=1, z=2, building is square in this algorithm widthoffset will be between 0 and (windowwidth + wallwidth) heightoffset will be between 0 and (windowheight + wallheight) ceiling - top where no more windows exist floor - bottom where no more windows exist */ #include "rayserver.h" #include "raytrace.h" #include "noises.h" #include "patterns.h" surface concrete_shiny_building (float Ka = .8, Kd = 0.75, Ks = 0.2, roughness = 0.2; color specularcolor = 1; color wallcolor = Cs; color windowcolor = color(1, .75, 0); float up = 2; float ceiling = 100, floor = -100; float windowwidth = 1, wallwidth = 1; float windowheight = 1, wallheight = 1; float widthoffset = 0, heightoffset = 0; float Kr = 0.5, blur = 0; float samples = 1; /* concrete features */ color concretecolor = color(0.682353, 0.643137, 0.643137); color Kc = .05 ) { normal Nf = faceforward(normalize(N),I); vector IN = normalize(I);; float xpart, ypart, zpart; float sum = 0; color ev = 0; if (up == 0){ xpart = abs(ycomp(P)); ypart = abs(zcomp(P)); zpart = abs(zcomp(P)); } else if (up == 1){ xpart = abs(zcomp(P)); ypart = abs(xcomp(P)); zpart = abs(ycomp(P)); } else{ xpart = abs(xcomp(P)); ypart = abs(ycomp(P)); zpart = abs(zcomp(P)); } Cs = wallcolor; xpart = mod((xpart + widthoffset), (windowwidth + wallwidth)); ypart = mod((ypart + widthoffset), (windowwidth + wallwidth)); zpart = mod((zpart + heightoffset), (windowheight + wallheight)); if (zpart <= floor) sum = 1; if (zpart >= ceiling) sum = 1; if (xpart > (wallwidth/2)) if (xpart < (windowwidth + (wallwidth/2))) sum = sum + 1; if (ypart > (wallwidth/2)) if (ypart < (windowwidth + (wallwidth/2))) sum = sum + 1; if (zpart > (wallheight/2)) if (zpart < (windowheight + (wallheight/2))) sum = sum + 1; if (sum == 0){ if (Kr > 0.001) { vector Rdir = normalize (reflect (IN, Nf)); ev = Kr * RayTrace (P, Rdir, blur, 1, samples); Cs = windowcolor; } }else{ /* * * inwallspace * */ float delta = .01 * snoise(P); concretecolor = (Kc * delta) + concretecolor ; Cs = concretecolor; } Ci = Cs * (Ka*ambient() + Kd*diffuse(Nf)) + specularcolor * (ev + Ks*specular(Nf,-IN,roughness)); Oi = Os; Ci *= Oi; }