#include "rmannotes.sl" surface binary_dream(float dots = 20, circles = 38, opac = .6, Ka = 1, Kd = 0.5; float Ks = 0.5, roughness = 0.1; color specularcolor = 1) /* This shader combines solid textures with bombing to create a harmony between color and geometry, thus the title, Binary Dream. */ { color paper, ink; float ink_opac; float fuzz = 0.025; color purple = color (.7,.2,.7); color yellow = color (.8,.8,0); color blue = color (0,.4,1); color green = color (0, .46,.9); color red = color (1,0,0); color amb,diff,spec; point center; float radius; float d,tmps,tmpt; float width, freq = 4; float disk, ring; float col,row,sp,ss,tt; float noi, noifreq = 3, noiscale = 1; point Nf, V; /* background */ sp = sin(s*1*PI); paper = mix(red, blue, smoothstep(0.3 - sp, 0.7 + sp, t)); ink = noise(s * 10, t * 10); paper = mix(paper,ink,.7); /* dot chunks w/bombing*/ col = whichtile(s, circles); row = whichtile(t, circles); noi = noise(col * 10 + 0.5, row * 10 + 0.5); tmps = repeat(s, circles) + udn(noi * 1183, -0.35, 0.35); tmpt = repeat(t, circles) + udn(noi * 999, -0.35, 0.35); rotate2d(tmps, tmpt, radians(udn(noi * 777, 0, 360)), 0.5, 0.5, ss, tt); /* dot chunks */ center = (0.5, 0.5, 0); radius = 0.2; d = distance(center, (ss, tt, 0)); disk = 1 - smoothstep(radius - fuzz, radius + fuzz, d); ink = green; ink_opac = disk * opac; paper = mix(paper, ink, ink_opac); /* yellow circles */ center = (0.1, 0.5, 0); radius = 0.5; width = 0.1; d = distance(center, (ss, tt, 0)); ring = pulse(radius - width / 2, radius + width / 2, fuzz, d); ink = yellow; ink_opac = ring * opac; paper = mix(paper, ink, ink_opac); /* green circles */ center = (0.51, 0.005, 0); radius = 0.6; width = 0.1; d = distance(center, (ss, tt, 0)); ring = pulse(radius - width / 2, radius + width / 2, fuzz, d); ink = color (.3,1,.4); ink_opac = ring * opac; paper = mix(paper, ink, ink_opac); /* blocks */ if (udn(noi * 314, 0, 1) > 0.6) { ink = color "hsv" (udn(noi * 8181, 0, 1), 1, 1); ink_opac = opac * intersection(pulse(0.25, 0.85, fuzz, ss), pulse(0.25, 0.65, fuzz, tt)); paper = mix(paper, ink, ink_opac); } /* plastic illumination */ Nf = faceforward(normalize(N), I); V = -normalize(I); amb = paper * Ka * ambient(); diff = paper * Kd * diffuse(Nf); spec = specularcolor * Ks * specular(Nf,V,roughness); Oi = Os; Ci = Os * (amb + diff + spec); }