/* Marla Mayerson */ /* This shader has a square pattern that rotates 45 degrees with gradient*/ /* color washes applied to the rectangles and disks*/ #include "rmannotes.sl" surface rect(float Ka = 1, Kd = 0.5; float Ks = 0.5, roughness = 0.1; color specularcolor = 1) { color paper, ink; float paper_opac; float ink_opac; float fuzz = 0.015; color yellow = color (1,1,0); color red = color (1, 0, 0); color orange = color "hsv" (0, 0.8, 1); float left, right, top, bottom; float ss, tt; float freq; color blue = color (0,0,1); point center; float radius; float d; point Nf, V; /* init */ Nf = faceforward(normalize(N), I); V = -normalize(I); /* paper */ paper = blue; /* set background color to blue */ paper_opac = 1; /* layer 1 - the rect */ /* rotate 45 degrees and repeat pattern 'freq" times horz,vert */ rotate2d(s, t, radians(45), 0.5, 0.5, ss, tt); freq = 9; /* number of repetitions of rect */ ss = repeat(ss, freq); tt = repeat(tt, freq); ink = spline(t, yellow, yellow, orange, red, red); left = 0.05; right = 0.75; /* rectangle sides */ top = 0.1; bottom = 0.7; ink_opac = pulse(left, right, fuzz, ss) * pulse(top, bottom, fuzz,tt); paper = mix(paper, ink, ink_opac); /* layer 2 - disk */ freq = 3; /*number of repetitions of disk */ ss = repeat(s, freq); tt = repeat(t, freq); ink = mix(blue, orange,s); center = (0.5, 0.5, 0); /* location of center of disk */ radius = 0.25; /* radius of disk */ d = distance(center, (ss, tt, 0)); ink_opac = 1 - smoothstep(radius - fuzz, radius + fuzz, d); paper = mix(paper, ink, ink_opac); /* plastic illumination for all layers */ paper = paper * Ka * ambient() + paper * Kd * diffuse(Nf) + specularcolor * Ks * specular(Nf, V, roughness); /* output */ Oi = paper_opac; Ci = paper_opac * paper; }