#include "rmannotes.sl" #define max_d distance((0, 0, 0), (0.5, 0.5, 0)) surface grid() { color paper, ink; float opac; float tile_s, tile_t; float low, hi, fuzz, d; point center, p; paper = Cs; /* define fuzz for antialiasing */ fuzz = 0.05; /* to generate 10 * 10 tiles */ tile_s = repeat(s, 10); tile_t = repeat(t, 10); low = 0.35; hi = 0.65; /* first layer with green color and vertical pattern */ ink = color (0, 1, 0); opac = pulse (tile_s, low, hi, fuzz); opac *= 0.5; paper = mix (paper, ink, opac); /* second layer with blue color and horizontal pattern */ ink = color (0, 0, 1); opac = pulse (tile_t, low, hi, fuzz); opac *= 0.5; paper = mix (paper, ink, opac); /* rotate coordinates to create rotated patterns */ rotate2d(s,t, 45, 0.6, 0.6, tile_s, tile_t); /* to generate 5 * 5 tiles */ tile_s = repeat(tile_s, 5); tile_t = repeat(tile_t, 5); /* calculate a distance between the center of the poligon and the current coordinate. An edge has a large value close to 1 and the center point has 0 value */ center = (0.5, 0.5, 0); p = (tile_s, tile_t, 0); d = distance(center, p); /* to define a varying width of the pulse */ low = d/(max_d *2); hi = d/max_d; /* third layer having varying width of line patterns */ ink = color (1, 0,0); opac = pulse (tile_s, low, hi, fuzz); opac *= hi; paper = mix (paper, ink, opac); /* fourth layer having varying width of line patterns */ ink = color (1, 1, 0); opac = pulse (tile_t, low, hi, fuzz); opac *= hi; paper = mix (paper, ink, opac); /* redefine the local coordinates for a new pattern */ tile_s = repeat(s, 4); /* last layer having four vertical columns */ ink = color (0.3, 0.3, 0.8); opac = smoothstep(0.1, 0.9, tile_s); opac *= 0.5; paper = mix (paper, ink, opac); Ci = paper; }