//-------------------------------------------------------------------------- // // Variations on the sunflower destribution based on the golden ratio // // Author: Ive 2020 // Copyright: whateverware (free as in beer) // // Command linee: use a square image format and a bit of anti aliasing e.g. // -w1200 -h1200 +AM2 +A0.05 +R3 // //-------------------------------------------------------------------------- #version 3.7; #global_settings {assumed_gamma 1.0} #default { finish {ambient 0 diffuse 0 specular 0} } #declare GoldenRatio = (1+sqrt(5))/2; //-------------------------------------------------------------------------- // CONTROL CENTER //-------------------------------------------------------------------------- // "Ratio" is meant to be the "Golden Ratio" but you can try other irrational // numbers, e.g. pi/16 or sqrt(3)/2 to get a spiral order, while all rational // numbers are quite boring. // // // "ColorStyle" for color variations // 1 = golden pedals on blue // 2 = green pedals on red // 3 = pink/white pedals on green // 4 = blue pedals on yellow // // // "PedalGradient" adds a color gradient to the pedals // 0 = turns gradient off (needs PedalReflect to be on, otherwise it gets uninteresting) // 1 = default gradient // 2 = inverse default gradient // // // "PedalShape" for pedal variations // 1 = default pedal // 2 = romboid with round edges // // // "PedalSize" should explains itself // // // "PedalDensity" density of the pedal destribution (needs to be > 0) // // // "PedalTilt" rotates the pedals towards the center (to avoid intersections) // // // "PedalMod1" and "PedalMod2" creates spiral color variations based on 2 modula functions. Make both of them > 0 to turns them on. // // // "PedalNoise" and "GroundNoise" adds color noise to the textures. Requires good antialiasing settings to look nice. // // // "PedalReflect" and "GroundReflect" adds reflections of the colored skydome to the textures. This effect is subtle but visible. // #declare Ratio = GoldenRatio; #declare ColorStyle = 1; #declare PedalGradient = 1; #declare PedalShape = 1; #declare PedalSize = 1.85; #declare PedalDensity = 1.85; #declare PedalTilt = 5; #declare PedalMod1 = 0; #declare PedalMod2 = 0; #declare PedalNoise = on; #declare PedalReflect = on; #declare GroundNoise = on; #declare GroundReflect = on; // Pedals start number (from the center) and count #declare Start = 1; #declare Count = 555; //-------------------------------------------------------------------------- // default settings: //-------------------------------------------------------------------------- #ifndef (Ratio) #declare Ratio = GoldenRatio; #end #ifndef (ColorStyle) #declare ColorStyle = 1; #end #ifndef (PedalShape) #declare PedalShape = 1; #end #ifndef (PedalSize) #declare PedalSize = 1.5; #end #ifndef (Start) #declare Start = 1; #end #ifndef (Count) #declare Count = 500; #end #ifndef (PedalDensity) #declare PedalDensity = 2; #end //-------------------------------------------------------------------------- // camera defintions camera { perspective location y*1.5 sky z look_at 0 angle 36 right x*image_width/image_height } //-------------------------------------------------------------------------- // skydome for the reflections sphere { 0, 1 pigment { average pigment_map { [1.0, gradient y color_map { [0, rgb <0.8, 0.85, 1> ] [1, rgb <0.5, 0.75, 1> ] } scale 2 translate -y ] [0.5, bozo color_map { [0.1, rgb < 1.0, 0.6, 0.6> ] [0.9, rgb < 0.0, 0.0, 0.0> ] } scale 0.5 translate x ] [0.5, bozo color_map { [0.1, rgb < 0.6, 1.0, 0.6> ] [0.9, rgb < 0.0, 0.0, 0.0> ] } scale 0.5 translate y ] [0.5, bozo color_map { [0.1, rgb < 0.6, 0.6, 1.0> ] [0.9, rgb < 0.0, 0.0, 0.0> ] } scale 0.5 translate z ] } } finish {emission 3} scale 3 no_shadow no_image } //-------------------------------------------------------------------------- // color definitions #switch (ColorStyle) #case (1) // golden pedals #declare CP_00 = rgb <0.25, 0.15, 0.02>; #declare CP_01 = rgb <0.75, 0.50, 0.02>; // blue background #declare CB = rgb <0.06, 0.15, 0.35>; #break #case (2) // green pedals #declare CP_00 = rgb <0.002, 0.06, 0.05>; #declare CP_01 = rgb <0.003, 0.33, 0.03>; // red background #declare CB = rgb <0.30, 0.08, 0.04>; #break #case (3) // pink/white pedals #declare CP_00 = rgb <0.65, 0.50, 0.65>; #declare CP_01 = rgb <0.80, 0.80, 0.80>; // green background #declare CB = rgb <0.15, 0.40, 0.12>; #break #case (4) // blue pedals #declare CP_00 = rgb <0.001, 0.06, 0.20>; #declare CP_01 = rgb <0.001, 0.15, 0.45>; // beige background #declare CB = rgb <0.65, 0.55, 0.10>; //****************** // add more styles here !!! //****************** #else #error "Undefined color style" #end #switch (PedalGradient) #case (0) #declare CP_TMP = (CP_00 + CP_01) / 2; #declare CP_00 = CP_TMP; #declare CP_01 = CP_TMP; #break #case (2) #declare CP_TMP = CP_00; #declare CP_00 = CP_01; #declare CP_01 = CP_TMP; #break #end #declare CP_10 = CP_00 * 0.95; #declare CP_11 = CP_01 * 1.05; #declare CP_001 = CP_00 * 1.25; #declare CP_011 = CP_01 * 1.25; #declare CP_101 = CP_001 * 0.95; #declare CP_111 = CP_011 * 1.05; //-------------------------------------------------------------------------- // finish definitions // pedal #declare FP = finish { #if (PedalReflect) ambient 0.2 reflection {2/3, 1 falloff 5 metallic } #else ambient 1 #end }; // background #declare FB = finish { #if (GroundReflect) ambient 0.2 reflection {1/3, 1 falloff 5 metallic } #else ambient 1 #end }; //-------------------------------------------------------------------------- #declare Scale = 0.01; #declare Dist = Scale * 1.45; //-------------------------------------------------------------------------- // the pedal csg object #declare Pedal = #switch (PedalShape) #case (1) intersection { difference { union { #declare R = Scale/3; box {<-Scale, 0, -Scale+R>, <0, Scale, 0> } box {<-Scale+R, 0, -Scale >, <0, Scale, 0> } cylinder {0, y*Scale, R translate <-Scale+R, 0, -Scale+R>} cylinder {0, y*Scale, Scale } rotate y*45 } sphere {0, Scale*5 translate y*Scale*5.1 } } sphere {0, Scale*5.1 translate y*Scale*5.1 } scale * PedalSize } #break #case (2) intersection { difference { union { #declare R = Scale/3; box {<-Scale, 0, -Scale+R>, } box {<-Scale+R, 0, -Scale >, } cylinder {0, y*Scale, R translate <-Scale+R, 0, -Scale+R>} cylinder {0, y*Scale, R translate <-Scale+R, 0, Scale-R>} cylinder {0, y*Scale, R translate < Scale-R, 0, -Scale+R>} cylinder {0, y*Scale, R translate < Scale-R, 0, Scale-R>} rotate y*45 } cylinder {<0, 0,-Scale*2>, <0, 0, Scale*2>, Scale*5 translate y*Scale*5.1 } } cylinder {<0, 0,-Scale*2>, <0, 0, Scale*2>, Scale*5.1 translate y*Scale*5.1 } scale * PedalSize } #break //*********************************** // add more shapes here !!! //*********************************** #else cylinder {0, y*Scale, Scale*2} #end //-------------------------------------------------------------------------- // macro to create an individual texture for each "pedal" where the base texture // remains the same but the overlaying noise (i.e. granite) is unique #macro TPedal(Idx) #if (!mod(Idx, PedalMod1) | !mod(Idx, PedalMod2)) #local P_00 = CP_001; #local P_01 = CP_011; #local P_10 = CP_101; #local P_11 = CP_111; #else #local P_00 = CP_00; #local P_01 = CP_01; #local P_10 = CP_10; #local P_11 = CP_11; #end #if (!PedalShape) pigment {CP_10} #else #local P_base = pigment { #if (PedalShape = 2) gradient x color_map { [0 P_00] [1 P_01] } translate -x*0.5 scale GoldenRatio * PedalSize * Scale * 2.55 #else spherical poly_wave 0.75 color_map { [0.0 P_01] [1.0 P_00] } scale * PedalSize * Scale #end // (PedalShape = 2) } #if (PedalNoise) pigment { average pigment_map { [1 P_base ] [1 granite color_map { [0 P_10] [1 P_11] } scale Scale*0.1 translate Idx*0.1 ] } } #else pigment {P_base} #end // (ColorNoise) #end // (!PedalShape) finish {FP} #end //-------------------------------------------------------------------------- // create the "sunflower" ornament based on the golden ratio #declare End = Count+Start-1; #for (K, Start, End) object { Pedal TPedal(K) rotate z*PedalTilt translate rotate -y*K*360*Ratio } #end //-------------------------------------------------------------------------- // create a colored background with subtle structure plane {y, -sqrt(End+1)*Scale*0.2 pigment { #if (GroundNoise) crackle metric 3 form <1,0,0.1> pigment_map { [0.2 CB * 0.6 ] [1.0 granite color_map { [0 CB * 1.0] [1 CB * 0.4] } scale 0.011 ] } turbulence 0.1 scale 1/3 #else CB * 0.7 #end } finish {FB} } //--------------------------------------------------------------------------