#include "rmannotes.sl" surface window (float wind_width = .65, wind_hight = .65, hor_bars = 1, vert_bars = 1, frame_h_width = .02, offset_freq = 1, offset_amp = 0, pair_offset = .15, store_front_floors = 2, rot_amp = 0; string reflect = "view.tex"; float reflect_amount = .5, reflection_noise = 5; float raws = 1, col = 1; float Km = .1; float Ka = .4, Kd = .4; float Ks = 0.6, roughness = 0.8; color specularcolor = 1, specularcolor_glass = color(.32, 1, 1); color specularcolor_wall = color(1, .63, 0), wall_color = color(.5, .6, .8), glass_color = color(.4, .4, .4), fr_color = color( .2, .3, .5) ) { color surface_color, layer_color; float layer_opac1, layer_opac2, layer_opac; float ss, tt, sss, ttt, sfreq, tfreq, d1, d2, d; float nfreq = 8, amp = .05, amp2 = .6, nfreq2 = 1.2; float i, j, fuzz = .01; float rot, bottom, top, left, right, offset; float hor_division = hor_bars+1, v_division = vert_bars +1; float h_size, v_size, in_left, in_top; float glass_area = 0, frame_area = 0; color amb, diff, spec; point Nf,V; float w_roughness = .2, w_Ks = .8, w_Kd = .4, w_Ka = .2; /*************illumination *****************************************/ Nf = faceforward(normalize(N), I); V = -normalize(I); /*******************************************************************/ sfreq = raws; tfreq = col; offset = snoise2((whichtile(s,sfreq)+.23)*offset_freq+50, (whichtile(t,tfreq)+.23)*offset_freq)*offset_amp; ss = mod(repeat(s, sfreq) + snoise((whichtile(s,sfreq)+.23)*offset_freq+50)*offset_amp + offset, 1); tt = mod(repeat(t, tfreq) + snoise((whichtile(t,sfreq)+.23)*offset_freq)*offset_amp + offset/2, 1); if(odd(whichtile(t,tfreq))) tt = mod(tt + pair_offset, 1); rot = snoise2(whichtile(s, sfreq)+.21, whichtile(t, tfreq)+.12)*rot_amp; rotate2d(ss, tt, rot_amp, .5, .5, sss, ttt); if(whichtile(t,tfreq) >= raws - store_front_floors) { bottom = 1; right = 1; left = 0; top = 0; } else{ bottom = 1 - (1 - wind_hight)/2; right = 1 - (1 - wind_width)/2; left = (1 - wind_width)/2; top = (1 - wind_hight)/2; } h_size = (right - left - (v_division+1)*frame_h_width)/v_division; v_size = (bottom - top - (hor_division+1)*frame_h_width)/hor_division; /*********** window area **********************************************/ frame_area = pulse(left, right, fuzz, sss) * pulse(top, bottom, fuzz, ttt); /************ glass area **********************************************/ for(i = 0; i < hor_division; i = i+1) /* raws */ { in_top = top +(i+1)*frame_h_width + i*v_size; layer_opac1 = pulse(in_top, in_top + v_size, fuzz, ttt); for(j = 0; j < v_division; j = j+1) /* columns */ { in_left = left + (j+1)*frame_h_width + j*h_size; layer_opac2 = pulse(in_left, in_left + h_size, fuzz, sss); layer_opac2 = intersection(layer_opac1, layer_opac2); glass_area = union(glass_area, layer_opac2); } } /* background layer (layer 0) */ amb = Cs * w_Ka * ambient() + w_Kd * diffuse(Nf); spec = specularcolor_wall * w_Ks * specular(Nf, V, w_roughness); surface_color = wall_color * (amb + spec); /* fr_color = color(1, 0, 0);*/ /* layer #1 frame */ amb = Cs * Ka * ambient(); diff = Cs * Kd * diffuse(Nf); spec = specularcolor * Ks * specular(Nf, V, roughness); layer_color = fr_color * (amb + diff); layer_opac = frame_area; surface_color = blend (surface_color, fr_color, layer_opac); /* layer #2 glass*/ layer_color = blend(glass_color, color texture(reflect, s,t), reflect_amount) ; layer_color += color noise(whichtile(s, raws) + s, whichtile(t, col) + t/4)*reflection_noise; layer_opac = glass_area; surface_color = blend(surface_color, layer_color, layer_opac); /* illumination */ amb = Cs * Ka * ambient(); diff = Cs * Kd * diffuse(Nf); /*spec = specularcolor * Ks * specular(Nf, V, roughness);*/ Oi = 1; Ci = surface_color * (amb + diff + spec); }