/* tree2.sl * * draws regular tree, purturbs to produce vienlike pattern, see thru * */ #include "rmannotes.sl" surface tree2( color treecolor = color(1,0,0); float treenumber = 1) { color paper, ink; float paper_opac, ink_opac; float ss, tt; float count; float hold; point center; float radius, width; float d; float noi; float fuzz = 0.025; float freq = 4; float noifreq = 5; float noiscale = 0.5; point p1, p2, p3, p4, p5; /* init */ paper = 0; paper_opac = 0; count = 0; hold = .05; /* compute base noise */ noi = noise(s * noifreq, t * noifreq); /* perturb ss, tt */ ss = s + snoise(noi + 912) * noiscale; tt = t + snoise(noi + 333) * noiscale; /*create tiles*/ ss = repeat(ss,treenumber); tt = repeat(tt,1) + noiscale/2.3; /*assign ink color*/ ink = treecolor; /*draw tree*/ p1 = (.5, 1, 0); p2 = (.5, 0.75, 0); width = .05; d = ptlined(p1, p2, (ss, tt, 0)); ink_opac =(1 - smoothstep(width / 2 - fuzz, width / 2 + fuzz, d)); paper = mix(paper, ink, ink_opac); paper_opac = paper_opac + ink_opac; p3 = ( .25 + .1, .5 + .1, 0); width = .04; d = ptlined(p2, p3, (ss, tt, 0)); ink_opac =(1 - smoothstep(width / 2 - fuzz, width / 2 + fuzz, d)); paper = mix(paper, ink, ink_opac); paper_opac = paper_opac + ink_opac; p4 = ( 0 + .15, .5 + .1, 0); width = .03; d = ptlined(p3, p4, (ss, tt, 0)); ink_opac =(1 - smoothstep(width / 2 - fuzz, width / 2 + fuzz, d)); paper = mix(paper, ink, ink_opac); paper_opac = paper_opac + ink_opac; p5 = ( .25 - 0.2, .5 - .005, 0); width = .02; d = ptlined(p4, p5, (ss, tt, 0)); ink_opac =(1 - smoothstep(width / 2 - fuzz, width / 2 + fuzz, d)); paper = mix(paper, ink, ink_opac); paper_opac = paper_opac + ink_opac; p5 = ( .25 - 0.2, .5 + .2, 0); width = .02; d = ptlined(p4, p5, (ss, tt, 0)); ink_opac =(1 - smoothstep(width / 2 - fuzz, width / 2 + fuzz, d)); paper = mix(paper, ink, ink_opac); paper_opac = paper_opac + ink_opac; p4 = ( .25 + .1, .25 + .15, 0); width = .03; d = ptlined(p3, p4, (ss, tt, 0)); ink_opac =(1 - smoothstep(width / 2 - fuzz, width / 2 + fuzz, d)); paper = mix(paper, ink, ink_opac); paper_opac = paper_opac + ink_opac; p5 = ( .25 + .2, .25 + .05, 0); width = .02; d = ptlined(p4, p5, (ss, tt, 0)); ink_opac =(1 - smoothstep(width / 2 - fuzz, width / 2 + fuzz, d)); paper = mix(paper, ink, ink_opac); paper_opac = paper_opac + ink_opac; p5 = ( .25 , .25 + .05, 0); width = .02; d = ptlined(p4, p5, (ss, tt, 0)); ink_opac =(1 - smoothstep(width / 2 - fuzz, width / 2 + fuzz, d)); paper = mix(paper, ink, ink_opac); paper_opac = paper_opac + ink_opac; p3 = ( .75 - .1, .5 + .1, 0); width = .04; d = ptlined(p2, p3, (ss, tt, 0)); ink_opac = (1 - smoothstep(width / 2 - fuzz, width / 2 + fuzz, d)); paper = mix(paper, ink, ink_opac); paper_opac = paper_opac + ink_opac; p4 = ( 1 - .15, .5 + .1, 0); width = .03; d = ptlined(p3, p4, (ss, tt, 0)); ink_opac =(1 - smoothstep(width / 2 - fuzz, width / 2 + fuzz, d)); paper = mix(paper, ink, ink_opac); paper_opac = paper_opac + ink_opac; p5 = ( .75 + 0.2, .5 - .005, 0); width = .02; d = ptlined(p4, p5, (ss, tt, 0)); ink_opac =(1 - smoothstep(width / 2 - fuzz, width / 2 + fuzz, d)); paper = mix(paper, ink, ink_opac); paper_opac = paper_opac + ink_opac; p5 = ( .75 + 0.2, .5 + .2, 0); width = .02; d = ptlined(p4, p5, (ss, tt, 0)); ink_opac =(1 - smoothstep(width / 2 - fuzz, width / 2 + fuzz, d)); paper = mix(paper, ink, ink_opac); paper_opac = paper_opac + ink_opac; p4 = ( .75 - .1, .25 + .15, 0); width = .03; d = ptlined(p3, p4, (ss, tt, 0)); ink_opac =(1 - smoothstep(width / 2 - fuzz, width / 2 + fuzz, d)); paper = mix(paper, ink, ink_opac); paper_opac = paper_opac + ink_opac; p5 = ( .75 - .2, .25 + .05, 0); width = .02; d = ptlined(p4, p5, (ss, tt, 0)); ink_opac =(1 - smoothstep(width / 2 - fuzz, width / 2 + fuzz, d)); paper = mix(paper, ink, ink_opac); paper_opac = paper_opac + ink_opac; p5 = ( .75 , .25 + .05, 0); width = .02; d = ptlined(p4, p5, (ss, tt, 0)); ink_opac =(1 - smoothstep(width / 2 - fuzz, width / 2 + fuzz, d)); paper = mix(paper, ink, ink_opac); paper_opac = paper_opac + ink_opac; /* output */ Oi = paper_opac; Ci = paper_opac * paper; }