// use these command line parameters to set the width/height // (right click on them and select "open include file/insert command line") // +w640 +h320 +AM2 +A0.2 // in any case, use a width that's twice the height. // good preview settings: // +w320 +h160 +sp4 // I figure we can add black areas at the top and bottom to make a good desktop image out of it when we're done. global_settings { max_trace_level 10 } #include "colors.inc" #include "woods.inc" #include "functions.inc" #declare usearealight = yes; #declare usenebula = yes; #declare useplanets = yes; #declare usestars = yes; #declare camloc = <0,0,-6>; #declare planetloc = <-120,40,300>; #declare planetscale = 80; #declare nebulaloc = <250,-65,500>; #declare nebulascale = 200; #declare rnd = seed(2422); camera { location camloc up y right 2*x look_at 0 } #declare colorrand = seed(2422); #macro RndColor() /*#local BAMT = 0; #local RAMT = int(5*rand(colorrand)); #local GAMT = int(2.5*rand(colorrand)); #if (GAMT >= RAMT) #local GAMT = 0; #local BAMT = int(3*rand(colorrand))+1; #end rgb /2*/ #local RAMT = rand(colorrand); #local GAMT = rand(colorrand); #local BAMT = rand(colorrand); rgb /max(RAMT,GAMT,BAMT) * (.7 + .3*rand(colorrand)) #end // Create an infinite sphere around scene and allow any pigment on it sky_sphere { pigment { granite color_map { [0.0 color rgbt 1] [0.1 color rgbt <.1,.2,.3, 1>] [0.4 color rgb <.15,.21,.33>] [0.8 color rgb <.25,.34,.6>*1.5] [1 color <.3,.6,.7>*2] } cubic_wave scale <4,1.25,2>*.8 } //pigment {bozo color_map {[0 rgb 0][1 rgb 1]} scale 1/4} /*#if (usestars) pigment { granite color_map { [0.0 color rgbt <10,10,10,0>] [0.05 color rgbt <1,1,1,0>] [0.1 color rgbt <1,1,1,0>] [0.2 color rgbt <1,1,1,1>]} scale .015 } #end*/ } #if (usestars) #declare starscale = 60; #declare stardist = 10000; #declare numstars = 3000; #declare starthetarange = 47; // horizontal range in degrees #declare starphirange = 28; // vertical range in degrees #declare starrand = seed(432); #declare densityscale = 4; #declare stardensity = function { f_noise3d(x*densityscale,y*densityscale,z*densityscale)/.85 *.75 + .25 } #declare brightstarrotate = 10; // rotates to the left #declare starmedia = media { emission 90 density { spherical color_map { [.3 rgb 0] // to dark [.325 rgb .5] [.35 rgb .65] // to medium [.375 rgb .5] [.4 rgb 0] [.5 rgb 0] // to dark [.55 rgb .7] [.6 rgb 1] [1 rgb 3] // bright } } } #declare star = cylinder { 0,z*.01,.75 pigment {rgbt 1} interior {media { // only using media to create an *additive* effect, so stars are brighter when in front of the blue nebula stuff starmedia method 2 samples 1,1 intervals 1 }} hollow } #declare starshinemedia = media { emission 70 density { spherical color_map { [0 rgb 0] // to dark [.1 rgb .7] [.2 rgb .95] [1 rgb 1] // from bright } } } #declare brightstar = cylinder { 0,z*.01,2.2 pigment {rgbt 1} interior {media { starmedia }media { starshinemedia scale <2.2,.13,1> }media { starshinemedia method 2 samples 1,1 intervals 1 scale <.13,2.2,1> }} hollow } // star parsing is sort of slow because of the way the density function is sampled; some stars require thousands of tests before they're placed #declare starnum = 0; #declare probabilityvalue = sqrt(rand(starrand))*.95; #while (starnum < numstars) #declare rotation = *; #declare starpoint = vrotate(z,rotation); #if (probabilityvalue < stardensity(starpoint.x,starpoint.y,starpoint.z)) object { #declare temprand = rand(starrand); #declare starsize = starscale*(.1 + temprand*.4 + pow(temprand,30)*1.5); #if (starsize >= 0.9*starscale) brightstar rotate z*brightstarrotate #else star #end scale <1,1,0>*starsize + z translate stardist*z rotate rotation } #declare starnum = starnum + 1; #declare probabilityvalue = sqrt(rand(starrand))*.95; #end //#debug concat(str(starnum,5,5), " ", str(probabilityvalue,5,5), "\n") #end #end #if (useplanets) light_group { // includes all but the nebula. avoids using area lighting on the nebula, which is unnecessary and would be *slow* light_source { #declare light_source_dist_mult = 100; #declare main_light_source_pos = <-5,3,-6>*light_source_dist_mult; #declare main_light_source_col = 1.3; main_light_source_pos rgb main_light_source_col #if (usearealight) area_light x*light_source_dist_mult*2,y*light_source_dist_mult*2,17,17 circular orient adaptive 1 jitter #end } // bowling ball //Layered Texture #declare ball_hole = union { cylinder { .5*1.7*y, y, .075} sphere {.5*1.7*y,.075 scale <1,.5,1>} difference { #declare roundedness = .008; #declare roundedness_error = .0038; cylinder { (1-roundedness-roundedness_error)*y,y,0.075+roundedness } torus { .075+roundedness,roundedness translate (1-roundedness-roundedness_error)*y } } rotate -45*x //pigment {rgb 1} } #macro ball() difference { sphere {0,1} object {ball_hole rotate <9,12.5,0>} object {ball_hole rotate <9,-12.5,0>} object {ball_hole rotate <-9,0,0>} texture { pigment { bozo color_map { //[0 rgb <.8,.3,1>][1 rgb <.3,1,.8>] [0 RndColor()][1RndColor()] } warp { turbulence 1 lambda 4 omega .4 octaves 3 } scale .3 } finish { diffuse 1 ambient 0 //brilliance 2 specular .4 roughness .01 //metallic } normal { dents .15 scale .05 } } texture { pigment { crackle color_map { [.5 RndColor() transmit 1] [.7 RndColor() transmit 0] } scale .06 } } hollow rotate x*-45 } #end // bowling pins // images.google.com + graph paper = helpful #declare numpinpoints = 12; #declare pinpoints = array[numpinpoints] {<0,-2>,<1,0>,<1.7,2>,<1.8,4>,<1.3,6>,<1,7>,<.75,8.3>,<.8,9.95>,<1,11.5>,<.8,12.5>,<.1,13>,<0,13>}; #declare pin = sor { numpinpoints, #declare pointnum=0; #while (pointnum < numpinpoints) pinpoints[pointnum] #if (pointnum < numpinpoints-1) , #end #declare pointnum = pointnum + 1; #end sturm scale 1/13 // goes from <0,0,0> to <0,1,0> pigment { gradient y color_map { //My best guesses :) #declare PinColor = <.995,1,.8>; #declare StripeColor = <.65,0,0>; [0 rgb <.95,.8,.4>] [.015 rgb <.95,.8,.4>] [.015 rgb PinColor] [7.15/13 rgb PinColor] [7.15/13 rgb StripeColor] [8/13 rgb StripeColor] [8/13 rgb PinColor] [9/13 rgb PinColor] [9/13 rgb StripeColor] [9.85/13 rgb StripeColor] [9.85/13 rgb PinColor] } } finish { diffuse .75 ambient 0 phong 1 phong_size 120 brilliance .75 //specular .3 //roughness .0001 } normal { dents .25 scale .06 } } // balls + pins #declare pin_radius = 1.4; // radius of pin's orbit #declare base_torus_func = function(a,b) { select(a-.1,0,select(a-.9,(a-.1)/.8,select(a-.945,1-(a-.9)/.045,0)))*pow(b,1-a) } #macro puff_of_light(major_rad, minor_rad, light_color, rotamnt) torus { major_rad, minor_rad rotate <7.5,0,90> translate z*-pin_radius rotate y*rotamnt interior { media { emission light_color } } } #end #macro ball_and_pin(pin_streak_color, pinaroundamnt,pinrot,sphererot) /* arguments: pin_streak_color is the color of the orbit of the pin pinaroundamnt is a number from 0 to 1 that specifies how far around the pin should be in its orbit pinrot and sphererot are vectors that the pin's orbit and the bowling ball will be rotated by */ union { union { merge { torus { 0.05, 0.007} cylinder { -.007*y, .007*y, .05 } rotate <15,0,90> translate z*-pin_radius rotate y*258.5 interior { media { emission 50*pin_streak_color } } } torus { 0.04, 0.006 rotate <12,0,90> translate z*-pin_radius rotate y*256.5 interior { media { emission 40*pin_streak_color } } } torus { 0.033, 0.005 rotate <9,0,90> translate z*-pin_radius rotate y*254.5 interior { media { emission 30*pin_streak_color } } } torus { 0.025, 0.0045 rotate <6,0,90> translate z*-pin_radius rotate y*252.5 interior { media { emission 15*pin_streak_color } } } torus { 0.02, 0.004 rotate <6,0,90> translate z*-pin_radius rotate y*250.5 interior { media { emission 7*pin_streak_color } } } /*sphere { 0.0, 0.005 //rotate <0,0,90> translate z*-pin_radius rotate y*250.5 interior { media { emission 5*pin_streak_color } } }*/ torus { pin_radius, pin_radius*0.01 interior { media { emission 30*pin_streak_color density { function { base_torus_func( (f_th(z,y,-x)+pi)/(2*pi), // amount around the orbit (1-sqrt(y*y+pow(sqrt(x*x+z*z)-pin_radius,2))/(pin_radius*0.02)) // distance from nearest point of orbit circle (torus function) ) } } } } } pigment {rgbt 1} hollow on rotate 90*x rotate -3*z } object { pin translate -.5*y scale pin_radius*.5 translate } rotate z*pinaroundamnt*360 rotate pinrot } object { ball() rotate sphererot } #end // place the "planets" //moved rnd to the top. #declare numballs = 150; #declare minballpos = <-50,-25,0>; #declare maxballpos = <50,25,50>; #declare ballrad = pin_radius*1.2; #declare ballposs = array[numballs]; //box {minballpos,maxballpos pigment {rgbt .5}} #declare ballnum = 0; #while (ballnum < numballs) union { ball_and_pin(, 0,*360, *360) // collision detection! don't let planets touch each other #declare posisok = false; #while (!posisok) #declare posisok = true; #declare pos = *(maxballpos-minballpos)+minballpos; // test against vision cone of the big planet #if (vdot(vnormalize(pos-camloc),vnormalize(planetloc-camloc)) > .96) // .91 for old position #declare posisok = false; #else // test against other balls #declare testballnum = 0; #while (testballnum < ballnum) #if (vlength(pos-ballposs[testballnum]) < ballrad) #declare posisok = false; #declare testballnum = ballnum; // break #end #declare testballnum = testballnum + 1; #end #end #end #declare ballposs[ballnum] = pos; // fake illusion of distance for farther spheres by shrinking them scale 1-pow(pos.z/maxballpos.z,1.7)*.9 translate pos } #declare ballnum = ballnum + 1; #end // the big'un union { //ball_and_pin(1/140*<.3,.7,1>, .8,<75,0,20>,<0,-10,5>) // for old position ball_and_pin(<.3,.7,1>/(planetscale*1.4), .77,<63,-25,25>,<-5,-25,20>) // for new position scale planetscale translate planetloc } global_lights } // end of light group #end // end of if(useplanets) // nebula #declare nebulacolor = <.4,.7,.6>*1.1; // make sure each component has at least a little color (not zero) and you get that nice fade-to-white oversaturation effect in the center #if (usenebula) light_group { light_source { // same as main light source, except not an area light main_light_source_pos rgb main_light_source_col } sphere { 0,1 pigment {rgbt 1} interior { media { scattering { // ah, the joy of slow renders 5, nebulacolor / nebulascale * 10 eccentricity .28 //makes it brighter where the light is coming from (the center in this case); check documentation for details } density { spherical poly_wave 1.5 scale 2 // reduces distortion effect of turbulence warp { turbulence .6 octaves 3 omega .6 lambda 4 } scale 1/2 // undoes scaling } density { bozo color_map {[0 rgb 0][.5 rgb .25][1 rgb 1]} poly_wave 1.5 warp { turbulence .65 octaves 2 omega .4 lambda 3 } scale .2 } } } hollow scale nebulascale translate nebulaloc } global_lights } #end light_source { nebulaloc rgb nebulacolor }