#include "rmannotes.sl" surface planet(color spot_color = color(.933,.415, .313), disk1_color = color(.545,.270,.074), disk2_color = color(1,.725,.058), line_color = color(.392,.584,.929), specularcolor = color (1, 1, 1); float Ks = 0.6, Kd = 0.4, Ka = 0.6, roughness = 0.3, radius1 = 0.35, radius2 = 0.15, radius4 = 0.05) { float attenuation = 2; point NN = normalize(N); point II = normalize(I); float falloff = II.NN; color surface_color, layer1_color, layer2_color, layer3_color, layer4_color; color surface_opac, layer1_opac, layer2_opac, layer3_opac, layer4_opac; float fuzz = 0.025, ss, tt, j, k ; point center, p1,p2, Nf, V; float half_width, dist1, dist2, dist3, dist4, r1, r2, r4; surface_color = Cs; surface_opac = 0.2; /* layer1 */ ss = repeat(s,2); tt = repeat(t,7); layer1_color = spot_color; center = (0.5, 0.5, 0); r1 = radius1 + (noise(ss, tt))*0.2; dist1 = distance(center, (ss, tt, 0)); layer1_opac = 1 - smoothstep(r1 - fuzz, r1, dist1); surface_color = blend(surface_color, layer1_color, layer1_opac); /*layer2 */ ss = repeat(s,5); tt = repeat(t,2); layer2_color = disk1_color; center = (0.5, 0.5, 0); r2 = radius2 + noise(ss*3, tt); half_width = 0.05; dist2 = distance(center, (ss, tt, 0)); layer2_opac = pulse(r2 - half_width, r2 + half_width, fuzz, dist2); surface_color = blend(surface_color, layer2_color, layer2_opac); /*layer3 */ ss = repeat(s,5); tt = repeat(t,5); layer3_color = line_color; p1 = (0.25, 0.5, 0); p2 = (0.35, 0.7, 0); half_width = 0.05; dist3 = ptlined(p1, p2, (ss,tt,0)); layer3_opac = 1 - smoothstep(half_width - fuzz, half_width, dist3); surface_color = blend(surface_color, layer3_color, layer3_opac); /*layer4*/ j = repeat(ss,3); k = repeat(tt,1); ss = repeat(s,3); tt = repeat(t,3); rotate2d(ss,tt, radians(70), 0.5, 0.5, j, k); layer4_color = disk2_color; center = (0.2, 0.2, 0); r4 = radius4 + noise(ss, tt*5); half_width = 0.05; dist4 = distance(center, (ss, tt, 0)); layer4_opac = pulse(r4 - half_width, r4 + half_width, fuzz, dist4); surface_color = blend(surface_color, layer4_color, layer4_opac); if (falloff < 0) { falloff = falloff * falloff / (II.II * NN.NN) ; falloff = pow(falloff, attenuation); Ci = surface_color * falloff; Oi = falloff; } else Oi = surface_opac; }