//Menger iso #include "colors.inc" #include "textures.inc" #version Unofficial MegaPOV 0.5; camera { location <9,-2,5> look_at <0,.5,0> } //camera { location <-2,0,1> look_at <-2,0,3> } light_source { <2000,3000,4000> rgb 1.0 } //light_source { -<2000,3000,4000> rgb 0.9 } light_source { <2000,-4000,3000> rgb 0.5 shadowless } global_settings { ambient_light 2 max_trace_level 100 } // +-------------------------------------------------------+ // | The Sponge | // +-------------------------------------------------------+ #declare _Z = function { if(min(abs(abs(x)%6-3)-2,abs(abs(y)%6-3)-2),1, if(min(abs(abs(x)%2-1)-2/3,abs(abs(y)%2-1)-2/3),1, if(min(abs(abs(x)%(2/3)-1/3)-2/9,abs(abs(y)%(2/3)-1/3)-2/9),1, if(min(abs(abs(x)%(2/9)-1/9)-2/27,abs(abs(y)%(2/9)-1/9)-2/27),1, if(min(abs(abs(x)%(2/27)-1/27)-2/81,abs(abs(y)%(2/27)-1/27)-2/81),1, if(min(abs(abs(x)%(2/81)-1/81)-2/243,abs(abs(y)%(2/81)-1/81)-2/243),1, //if(min(abs(abs(x)%(2/243)-1/243)-2/729,abs(abs(y)%(2/243)-1/243)-2/729),1, -1) //) ) ) ) ) ) } #declare _Y = function { if(min(abs(abs(x)%6-3)-2,abs(abs(z)%6-3)-2),1, if(min(abs(abs(x)%2-1)-2/3,abs(abs(z)%2-1)-2/3),1, if(min(abs(abs(x)%(2/3)-1/3)-2/9,abs(abs(z)%(2/3)-1/3)-2/9),1, if(min(abs(abs(x)%(2/9)-1/9)-2/27,abs(abs(z)%(2/9)-1/9)-2/27),1, if(min(abs(abs(x)%(2/27)-1/27)-2/81,abs(abs(z)%(2/27)-1/27)-2/81),1, if(min(abs(abs(x)%(2/81)-1/81)-2/243,abs(abs(z)%(2/81)-1/81)-2/243),1, //if(min(abs(abs(x)%(2/243)-1/243)-2/729,abs(abs(z)%(2/243)-1/243)-2/729),1, -1) //) ) ) ) ) ) } #declare _X = function { if(min(abs(abs(z)%6-3)-2,abs(abs(y)%6-3)-2),1, if(min(abs(abs(z)%2-1)-2/3,abs(abs(y)%2-1)-2/3),1, if(min(abs(abs(z)%(2/3)-1/3)-2/9,abs(abs(y)%(2/3)-1/3)-2/9),1, if(min(abs(abs(z)%(2/9)-1/9)-2/27,abs(abs(y)%(2/9)-1/9)-2/27),1, if(min(abs(abs(z)%(2/27)-1/27)-2/81,abs(abs(y)%(2/27)-1/27)-2/81),1, if(min(abs(abs(z)%(2/81)-1/81)-2/243,abs(abs(y)%(2/81)-1/81)-2/243),1, //if(min(abs(abs(z)%(2/243)-1/243)-2/729,abs(abs(y)%(2/243)-1/243)-2/729),1, -1) //) ) ) ) ) ) } isosurface { function { _X(x,y,z) & _Y(x,y,z) & _Z(x,y,z) } //function { -1 } contained_by { box { -3,3 } } max_gradient 100 //pigment { // color (SteelBlue+DarkSlateGray+Gray90+Gray90)/4 //} //normal { wrinkles .4 scale .001 } //finish { ambient .15 diffuse .55 } texture { pigment { color rgb<.00,.3,.4> } finish { ambient .15 diffuse .55 reflection_min .3 reflection_max .6 conserve_energy } } } // +-------------------------------------------------------+ // | The ground | // +-------------------------------------------------------+ #declare _F = function { pigment { wrinkles } } isosurface { function { y+noise3d(x/4,0,z/4)*1+_F(x,0,z)*.5+2.25 } max_gradient 2 contained_by { box { <-2500,-4,-2500>,<2500,-2,2500> } } pigment { color rgb <.6,1,.2> } } // +-------------------------------------------------------+ // | the atmosphere | // +-------------------------------------------------------+ fog { fog_type 1 color rgb .8 distance 600 } plane { y,102 hollow no_shadow pigment { color rgb<.3,.5,.8> } finish { ambient .5 diffuse 0 } } plane { y,101 hollow no_shadow pigment { wrinkles turbulence .6 octaves 8 lambda 2.5 omega .7 color_map { [0.00 rgbt<.7,.7,.7,0>] [0.35 rgbt<.7,.7,.7,0>] [0.45 rgbt<1,1,1,1>] [1.00 rgbt<1,1,1,1>] } scale 300 translate <-40,0,-40> } finish { ambient .5 diffuse 0 } } plane { y,100 hollow pigment { wrinkles turbulence .8 octaves 8 lambda 2.5 omega .7 color_map { [0.00 rgbt<.9,.9,.9,0>] [0.30 rgbt<.8,.8,.8,0>] [0.50 rgbt<1,1,1,1>] [1.00 rgbt<1,1,1,1>] } scale 300 } finish { ambient .5 diffuse 0 } } // +-------------------------------------------------------+ // | the trees | // +-------------------------------------------------------+ #include "mapleleaf.inc" // Tree( // Bottom of trunk, // Top of trunk, // Recursion level, // Branches at each vertex, // Parent:child length ratio, // Parent:child diameter ratio, // Angle between child and parent branch, // Randomness of endpoints, // Blob componenets per branch, // Crookedness (not implemented), // Bumpiness, // Radius of trunk, // Leaves per low-level branch, // Size of leaves, // Leaf object, // Leaf textures array (3), // Leaf texture weights array (3), // Bark texture, // Seeds array (4) // ) #macro Tree(Start,End,Rec,B,Lr,Sr,Ang,Ar,Res,Cr,Bm,Rad,Density,Size,Leaf,LText,LWeight,BText,Seeds) #local ASeed = Seeds[0]; #local CSeed = Seeds[1]; #local RSeed = Seeds[2]; #local LSeed = Seeds[3]; #local nleaves=pow(B,Rec); #local zeros=array[nleaves] #local zeroe=array[nleaves] #declare lpoint=0; blob { qTree(Start,End,Rec,B,Lr,Sr,Ang,Ar,Res,Cr,Bm,Rad,ASeed,CSeed,RSeed) texture { BText } } union { MakeLeaves(nleaves,zeros,zeroe,Density,Size,LSeed,Leaf,LText,LWeight) normal { wrinkles .2 } } #end #macro qTree(Start,End,Rec,B,Lr,Sr,Ang,Ar,Res,Cr,Bm,Rad,ASeed,CSeed,RSeed) #local ARnd = seed(ASeed); #local CRnd = seed(CSeed); #local RRnd = seed(RSeed); #local ctr = 0; #local len=sqrt(pow(End.x-Start.x,2)+pow(End.y-Start.y,2)+pow(End.z-Start.z,2)); #while (ctr < Res) sphere { Start+(End-Start)*(Res-ctr)/Res+*Bm*Rad,Rad*(1-(1-Sr)*(Res-ctr)/Res),1.0 } #local ctr = ctr + 1; #end #local rotC = ; #if (Rec = 0) #declare zeros[lpoint] = Start; #declare zeroe[lpoint] = End; #declare lpoint = lpoint + 1; #end #if (Rec > 0) #local nlen = len * Lr; #local ctr = 0; #while (ctr < B) #local RAO = rand(RRnd); qTree(End,vrotate(,rotC) +End+*Ar*nlen, Rec-1,B,Lr,Sr,Ang,Ar,Res,Cr,Bm,Rad*Sr,rand(ARnd)*65535,rand(CRnd)*65535,rand(RRnd)*65535) #local ctr = ctr + 1; #end #end #end #macro MakeLeaves(numbranch,Start,End,Density,Size,LSeed,Leaf,LTexture,LW) #local LRnd = seed(LSeed); #local ctr1 = 0; #while (ctr1 < numbranch) #local len=sqrt(pow(End[ctr1].x-Start[ctr1].x,2)+pow(End[ctr1].y-Start[ctr1].y,2)+pow(End[ctr1].z-Start[ctr1].z,2)); #local rotC = ; #local ctr = 0; #while (ctr < Density) object { Leaf scale Size*(rand(LRnd)*.4+.8) rotate rand(LRnd)*180*y rotate rotate rotC translate End[ctr1]-(End[ctr1]-Start[ctr1])*(ctr/Density) texture { pigment { average pigment_map { [rand(LRnd)*LW[0] LTexture[0]] [rand(LRnd)*LW[1] LTexture[1]] [rand(LRnd)*LW[2] LTexture[2]] } } } } #local ctr = ctr + 1; #end #local ctr1 = ctr1 + 1; #end #end #declare Bark = texture { pigment { color DarkTan*1.2 } normal { crackle 0.4 slope_map { [0.0 <0,1>][0.2 <1,0>][0.8 <1,0>][1.0 <0,-1>] } scale 0.05 } } #declare LeafTextureArray = array[3] { pigment { color Goldenrod*1.4 }, pigment { color Orange*1.4 }, pigment { color Scarlet*1.4 } } #declare LeafTextureWeights = array[3] { .4,1,.2 } #declare seeds = array[4] {418,418,418,418} union { Tree(<6,-3,5>,<6,-2.3,5>,4,5,.6,.6,40,.4,20,.3,.3,.15,7,.045,mapleleaf,LeafTextureArray,LeafTextureWeights,Bark,seeds) } #declare seeds = array[4] {4365,2435,567,325} union { Tree(<5,-3,-2.4>,<5,-2.3,-2.4>,4,5,.6,.6,40,.4,20,.3,.3,.15,7,.045,mapleleaf,LeafTextureArray,LeafTextureWeights,Bark,seeds) } #declare seeds = array[4] {79,965,9653,143} union { Tree(<-5.0,-3,-15.0>,<-5.0,-2.1,-15.0>,4,5,.6,.6,40,.4,20,.3,.3,.15,7,.045,mapleleaf,LeafTextureArray,LeafTextureWeights,Bark,seeds) } #declare seeds = array[4] {5468,13,789,153} union { Tree(<-2.0,-3,4.0>,<-2.0,-2.4,4.0>,4,5,.6,.6,40,.4,20,.3,.3,.15,7,.045,mapleleaf,LeafTextureArray,LeafTextureWeights,Bark,seeds) } #declare seeds = array[4] {5,6,7,8} union { Tree(<10.0,-3,-2.0>,<10.0,-2.2,-2.0>,4,5,.6,.6,40,.4,20,.3,.3,.15,7,.045,mapleleaf,LeafTextureArray,LeafTextureWeights,Bark,seeds) }