/* Eric Zimmerman description: This is the shader I used in my animation for the sun. It combines perturbed radial lines and bombed dots over a noise-based background that can change over time. parameters: The variables "frame" and "var" control the change in noise over time. The variables "xnum" "ynum" and "rad" control the centering and scaling of some of the elements. Lastly, "lines" and "lcolor" are used to control the darkness and opacity of the radial lines. */ #include "rmannotes.sl" surface final1 (float frame = 12, var = 10, xnum = 0, ynum = 0, rad = 1, lines = .5, lcolor = .3;) { color paper, ink; float opac, fuzz; float d, d2, lw, count, r; float tile_s, tile_t; float noi, noifreq, noiscale; float ran_g, ran_b; float noix, noiy; point dotloc, dotloc2; float dotfreq, tile_i, tile_j, numdots; noifreq = 9; noiscale = .5; /* generate "background" colors */ fuzz = .01; tile_s = s+ xnum; tile_t = t+ ynum; paper = noise ((tile_s + (frame/.037)) * var, (tile_t + (frame/.041)) * var); /* determine random, dark red-ish color for wiggly radiating lines */ ran_g = (s * ((frame+.1) /.772)); ran_b = (t * ((frame+.1) /.898)); ink = color ( .5, (udn (ran_g, 0, 1)), (udn (ran_b, 0, 1))); ink = ink * lcolor; /* perterb s & t for wiggly radiating lines */ noi = noise (s * noifreq, t * noifreq); tile_s = s + snoise(noi + 876) * noiscale; tile_t = t + snoise(noi + 112) * noiscale; tile_s = tile_s + xnum; tile_t = tile_t + ynum; /* calculate radiating lines from center along axes in .4 increments (20 lines total) */ fuzz = .03; lw = .005; for (count = 0; count < 2.1; count = count + .4) { d = ptlined((count, 2, 0), (.5, .5, 0), (tile_s, tile_t, 0)); opac = 1-smoothstep (lw-fuzz, lw+fuzz, d); paper = mix (paper, ink, opac); } for (count = 0; count < 2.1; count = count + .4) { d = ptlined((count, -1, 0), (.5, .5, 0), (tile_s, tile_t, 0)); opac = 1-smoothstep (lw-fuzz, lw+fuzz, d); paper = mix (paper, ink, opac); } for (count = 0; count < 2.1; count = count + .4) { d = ptlined((2, count, 0), (.5, .5, 0), (tile_s, tile_t, 0)); opac = 1-smoothstep (lw-fuzz, lw+fuzz, d); paper = mix (paper, ink, opac); } for (count = 0; count < 2.1; count = count + .4) { d = ptlined((-1, count, 0), (.5, .5, 0), (tile_s, tile_t, 0)); opac = 1-smoothstep (lw-fuzz, lw+fuzz, d); opac *= lines; paper = mix (paper, ink, opac); } /* generate bombed "dots" for sun center, number of dots = "numdots" dots can be tiled by changing "dotfreq" */ fuzz = .01; r = .03; dotfreq = 1; numdots = 80; tile_s = repeat(s, dotfreq); tile_t = repeat(t, dotfreq); tile_i = floor (s * dotfreq); tile_j = floor (t * dotfreq); /* the bombing */ for (count = 0; count < numdots; count = count + 1) { noix = noise(tile_i * 15 + (count + frame/.27)); noiy = noise(tile_j * 15 + (count - frame/.86)); dotloc = (snoise(noix * 45.3), snoise(noiy * 774.7), 0); d = distance(dotloc, (tile_s, tile_t, 0)); /* randomly determine ink for bombed dots from among 5 colors */ r = udn(count*12.7, 0, 100); if r < 20 ink = color (.383, 0, 1); else if r < 40 ink = color (1, .649, 0); else if r < 60 ink = color (.649, 1, 0); else if r < 80 ink = color (0, .316, 1); else ink = color (.695, .15, 0); ink *= .8; opac = 1 - smoothstep(.02, .03, d); opac *= .5; paper = mix(paper, ink, opac); } /* put a red/yellow transparent filter over everything */ tile_s = s + xnum; tile_t = t + ynum; r = rad; d = distance ((0, 0, 0), (tile_s, tile_t, 0)); ink = spline (d, color(1, 1, 0), color(1, 1, 0), color(1, .8, 0), color(1, .6, 0), color(1, .4, 0), color(1, .2, 0), color(1, 0, 0), color (1, 0, 0), color (1, 0, 0), color(1, 0, 0), color(1, 0, 0)); opac = 1 - smoothstep(r - fuzz, r + fuzz, d); opac *= .4; paper = mix (paper, ink, opac); Ci = paper; }