global_settings { assumed_gamma 1.0 max_trace_level 25 } // these are the functions to give local x and y values ... #declare fn_crack = function { pigment { crackle form <1,0,0> } } #declare fn_crackn = function { pigment { crackle } } #declare fn_x = function { fn_crack(x,y,z)*(fn_crack(x+0.005,y,z)-fn_crack(x-0.005,y,z))/0.01 } #declare fn_y = function { fn_crack(x,y,z)*(fn_crack(x,y+0.005,z)-fn_crack(x,y-0.005,z))/0.01 } #declare fn_z = function { fn_crack(x,y,z)*(fn_crack(x,y,z+0.005)-fn_crack(x,y,z-0.005))/0.01 } // Swirl Macro: produce pseudo random swirls in a given pigment // // R = average radius of each swirl // Amount = max number of half revolutions in swirl // Power = 'centralisation' of swirl // pig = pigment to swirl // #macro Swirl (R,Amount,Power,pig) #local A = pi*Amount/3; #local IR = 1/R; #local fn_ang = function { A*fn_crackn(x*IR,y*IR,z*IR)*(1-fn_crack(x*IR,y*IR,z*IR))^(Power-1) } #local fn_pig = function { pigment { pig } } #local fn_LT1 = function { fn_pig( x+R*(fn_x(x*IR,y*IR,z*IR)*(cos(fn_ang(x,y,z))-1)-fn_y(x*IR,y*IR,z*IR)*sin(fn_ang(x,y,z))), y+R*(fn_x(x*IR,y*IR,z*IR)*sin(fn_ang(x,y,z)+fn_y(x*IR,y*IR,z*IR)*(cos(fn_ang(x,y,z))-1))), z ) } #local fn_LT2 = function { fn_LT1( x+R*(fn_x(x*IR,y*IR,z*IR)*(cos(fn_ang(x,y,z))-1)-fn_y(x*IR,y*IR,z*IR)*sin(fn_ang(x,y,z))), y+R*(fn_x(x*IR,y*IR,z*IR)*sin(fn_ang(x,y,z)+fn_y(x*IR,y*IR,z*IR)*(cos(fn_ang(x,y,z))-1))), z ) } function { fn_LT2( x+R*(fn_x(x*IR,y*IR,z*IR)*(cos(fn_ang(x,y,z))-1)-fn_y(x*IR,y*IR,z*IR)*sin(fn_ang(x,y,z))), y+R*(fn_x(x*IR,y*IR,z*IR)*sin(fn_ang(x,y,z)+fn_y(x*IR,y*IR,z*IR)*(cos(fn_ang(x,y,z))-1))), z ) } #end // SwirlVar Macro: produce pseudo random swirls in a given pigment, // swirl amount controlled by another pigment, a multiplier and an offset. // // R = average radius of each swirl // Amount = pigment to control max number of half revolutions in swirl // Mult = multiplier to apply to 'Amount' pigment // Off = offset to apply to multiplied amount pigment // max swirl is given by Off + Mult * Amount(x,y,z) // Power = 'centralisation' of swirl // pig = pigment to swirl // #macro SwirlVar (R,Amount,Mult,Off,Power,pig) #local A = pi/3; #local IR = 1/R; #local fn_amt = function { pigment { Amount } } #local fn_ang = function { (Off+Mult*fn_amt(x,y,z))*A*fn_crackn(x*IR,y*IR,z*IR)*(1-fn_crack(x*IR,y*IR,z*IR))^(Power-1) } #local fn_pig = function { pigment { pig } } #local fn_LT1 = function { fn_pig( x+R*(fn_x(x*IR,y*IR,z*IR)*(cos(fn_ang(x,y,z))-1)-fn_y(x*IR,y*IR,z*IR)*sin(fn_ang(x,y,z))), y+R*(fn_x(x*IR,y*IR,z*IR)*sin(fn_ang(x,y,z)+fn_y(x*IR,y*IR,z*IR)*(cos(fn_ang(x,y,z))-1))), z ) } #local fn_LT2 = function { fn_LT1( x+R*(fn_x(x*IR,y*IR,z*IR)*(cos(fn_ang(x,y,z))-1)-fn_y(x*IR,y*IR,z*IR)*sin(fn_ang(x,y,z))), y+R*(fn_x(x*IR,y*IR,z*IR)*sin(fn_ang(x,y,z)+fn_y(x*IR,y*IR,z*IR)*(cos(fn_ang(x,y,z))-1))), z ) } function { fn_LT2( x+R*(fn_x(x*IR,y*IR,z*IR)*(cos(fn_ang(x,y,z))-1)-fn_y(x*IR,y*IR,z*IR)*sin(fn_ang(x,y,z))), y+R*(fn_x(x*IR,y*IR,z*IR)*sin(fn_ang(x,y,z)+fn_y(x*IR,y*IR,z*IR)*(cos(fn_ang(x,y,z))-1))), z ) } #end // end of the setup, now comes the scene ... // globe ... sphere { 0, 10 texture { function { pigment { average pigment_map { [1 planar] [1 bozo lambda 3 omega -0.5 octaves 6 turbulence 0.2 triangle_wave scale 0.2 colour_map {[0 rgb 0.15][0.5 rgb 0][1 rgb 0.25]} ] } } } turbulence 0.1 scale 10 texture_map { [0.2 pigment { rgb 1 } finish { ambient 0 diffuse 1 reflection 0.7 } normal { granite 0.05 scale 0.02 }] [0.2 bozo lambda 3 omega -0.5 octaves 6 turbulence 0.2 triangle_wave scale 0.2 texture_map { [0.5 pigment { granite scale 2 pigment_map { [0.0 planar scale 2 colour_map {[0 rgb 0.3][0.3 rgb <.2,.3,.2>][0.6 rgb <.1,.5,.1>][1 rgb <.4,.3,.2>]} ] [1 rgb 0.4] } } normal { granite 0.5 scale 2 } finish { ambient 0 diffuse 0.8 specular 0.2 metallic 0.3 } ] [0.5 pigment { rgb <.2,.3,.7> } finish { ambient 0 specular 1 reflection 0.4 diffuse 0.3 metallic 0.5 } normal { granite 0.05 scale 0.02 } ] } ] } } } // pigment to swirl ... #declare P1 = pigment { granite pigment_map { [0 colour rgb 0] [0.6 granite scale 0.1/<5,1,5> colour_map { [0 rgb 0.5] [1 rgb 1] } ] } scale <5,1,5> } // pigment to control amount of swirl ... #declare A1 = pigment { gradient y translate -0.5*y scale 20 colour_map {[0 rgb 0.5][0.35 rgb 1][0.4 rgb 1][0.6 rgb 0][0.65 rgb 0][1 rgb 0.5]}} // swirled pigment ... #declare SP3 = pigment { function { pigment { average pigment_map { [1 SwirlVar (3,A1,20,-10,5,P1)] [1 planar scale 10 colour_map {[0.6 rgb 0.4][1 rgb 0.2]} ] } } } } // clouds ... sphere { 0, 10.03 texture { pigment { SP3 colour_map {[0.3 rgbt 1][.5 rgb <1,.95,.9>][1 rgb <.4,.35,.4>] } } finish { ambient 0 diffuse 1 roughness 10 } } } background { rgb 0 } #declare LP = <20000,10000,-30000>; light_source { 0 colour rgb <1,1,.95> looks_like { sphere { 0, vlength(LP)*sin(radians(0.25)) pigment { rgb 1 } finish { ambient 1 diffuse 0 } } } translate LP } #declare CP = <0,5,-30>; #declare CL = 0*x; #declare CD = z; #declare CU = y; #declare CR = x*4/3; camera { location CP up CU right CR direction CD look_at CL } // star field adapted from J. Van S.'s page #declare CDL = vlength(CD); #declare CUL = vlength(CU); #declare CRL = vlength(CR); #declare RES = 480; #declare Dir=vnormalize(CL-CP); #declare Dist=2*RES*CDL; #declare Fore=CDL/sqrt(CDL*CDL+CUL*CUL/4+CRL*CRL/4); #declare S1=seed(1); #declare S2=seed(10); #declare Count=0; #while (Count<10000) #declare Star=vrotate(z,*360); #if (vdot(Dir,Star)>Fore) sphere { Star,1/Dist pigment { rgb (1-.5*)*0.75*(1+rand(S2)) } finish { diffuse 0 ambient 1 } no_shadow scale 2000 translate CP } #end #declare Count=Count+1; #end