/********************************************************************************** Persistence of Vision Ray Tracer Scene Description File File name : 00-MediaTree_test.pov Version : 3.8 Description : A media tree (and planting code) as proposed by Gilles Tran in MakeClouds. Can be used as vegetation on the background of a landscape. Two macros are proposed: the original and an updated one. Author : Gilles Tran (2003) http://www.oyonale.com/image.php?code=431&mode=info§ion=2003&lang=fr Updated : Thomas de Groot (2021) **********************************************************************************/ //+w1000 +h460 +a0.3 +am2 +bm2 +bs8 +wt7 #version 3.8; #include "colors.inc" #include "rand.inc" global_settings { assumed_gamma 1.0 radiosity { pretrace_start 0.08 // start pretrace at this size pretrace_end 0.01 // end pretrace at this size count 10, 100 // higher -> higher quality (1..1600) [35] nearest_count 5 // higher -> higher quality (1..10) [5] error_bound 1.8 // higher -> smoother, less accurate [1.8] recursion_limit 2 // how much interreflections are calculated (1..5+) [3] low_error_factor 0.5 // reduce error_bound during last pretrace step gray_threshold 0.0 // increase for weakening colors (0..1) [0] minimum_reuse 0.015 // reuse of old radiosity samples [0.015] brightness 1 // brightness of radiosity effects (0..1) [1] adc_bailout 0.01/2 normal on // take surface normals into account [off] media on // take media into account [off] always_sample off // turn sampling in final trace off [off] //max_sample 1.0 // maximum brightness of samples } } //-------------------------------------------------------------------------- // camera ------------------------------------------------------------------ #declare CamLoc = 1; //0=single tree; 1=wooded park land #switch (CamLoc) #case (0) //single tree test camera { location <0.0 , 10 , -150.0> right x*image_width/image_height angle 75 look_at <0.0 , 10 , 0.0> } #break #case (1) //wooded park land camera { location <0.0 , 300 , -2500.0> right x*image_width/image_height angle 75 look_at <0.0 , 0 , 0.0> } #end // sun --------------------------------------------------------------------- #local SunCol = srgb <0.9, 0.9, 0.8>; light_source {<-500, 1000, -1500>*10 SunCol*3} // sky --------------------------------------------------------------------- sphere { 0, 1 hollow pigment { gradient <0, 1, 0> color_map { [0.00 srgb <0.98, 0.98, 0.98>] [0.30 srgb <0.00, 0.10, 0.98>] [0.70 srgb <0.00, 0.10, 0.98>] [1.00 srgb <0.98, 0.98, 0.98>] } scale 2 } finish { emission 1 diffuse 0 } scale 10e4 } //-------------------------------------------------------------------------- //---------------------------- objects in scene ---------------------------- //-------------------------------------------------------------------------- // Two macros to create a media-filled sphere that looks like a tree #declare T_Clear = texture {pigment {Clear} finish {ambient 0 diffuse 0}} // This version is the original by Gilles Tran #macro WildTree(Trd) #local SC = rand(Trd)+1; #if (rand(Trd) < 0.2) // yellowish #local C_Media = <28+rand(Trd)*30, 44+rand(Trd)*10, 42>/255; #else // blueish #local C_Media = <28+rand(Trd)*10, 53+rand(Trd)*10, 49>/255; #end sphere {0, 2 texture {T_Clear} hollow interior { media { scattering {1, C_Media*(0.3+rand(Trd)*0.3)} absorption (1-C_Media*(0.1+rand(Trd)*0.4)) samples 1 density { spherical turbulence 0.5+rand(Trd) lambda 2.5+rand(Trd) rotate y*360*rand(Trd) translate y*rand(Trd)*0.5 } } } translate y*0.6 scale 2+rand(Trd)*7 scale 1.5* } #end //of media tree macro //=============================================================================== // This version is the updated one by Thomas de Groot #macro Tree(Trd) #if (RRand(0, 1, Trd) > 0.75) // yellowish #local C_Media = /255; #else // blueish #local C_Media = /255; #end sphere {0, 1 texture {pigment {rgb 1 transmit 1} finish {diffuse 1.0}} hollow interior { media { scattering {1, C_Media*0.05} absorption (1-C_Media*RRand(0.5, 0.9, Trd)) samples 1 density { spherical density_map { [0.1 rgb 0.0] [0.4 rgb 1.0] } scale 1/2 warp { turbulence RRand(0.1, 0.2, Trd) } scale 2 translate 0.2*y } density { spherical density_map { [0.0 rgb 0.0] [0.3 rgb 0.1] [0.4 rgb 0.7] [0.5 rgb 0.9] [0.6 rgb 0.8] [0.8 rgb 1.0] } warp { turbulence RRand(0.1, 0.5, Trd) lambda 5.5+RRand(1, 5, Trd) } } } } scale RRand(2, 5, Trd) scale RRand(<3, 5, 3>, <5, 15, 5>, Trd) rotate RRand(-180, 180, Trd)*y translate RRand(10, 15, Trd)*y //not sure about this. Seems to show a better result... ;-) } #end //of media tree macro //=============================================================================== #declare Wrd = seed(749382); #declare Trd = seed(7493); #declare Typ = 0; //which macro to use: 0=original, WildTree(); 1=updated Tree() #if (CamLoc = 0) // single tree: #if (Typ = 0) object { WildTree(Trd) } #else object { Tree(Trd) } #end #declare Terrain = plane {y, 0 pigment {srgb <0.5, 0.6, 0.1>} normal {granite 1 scale 0.01} finish {diffuse 0.7}} Terrain #else // Height_field for planting trees: #declare F_HF_01 = function { pigment { image_map {png "plasma3.png" gamma 1.0 //once map_type 0 interpolate 2 } } } #declare Terrain = height_field { function 2000, 2000 {F_HF_01(x,y,z).hf} translate <-0.5, -0.5, -0.5> scale <5000, 100, 5000> texture {pigment {srgb <0.5, 0.6, 0.1>} normal {granite 1 scale 0.01} finish {diffuse 0.7}} } // Planting the trees: #declare Woods = union { #declare i = 0; #while (i < 3000) #declare Start = VRand_In_Box(<-2500,1000,-2500>, <2500, 1001, 2500>, Wrd); #declare Norm = <0,0,0>; #declare Inter = trace (Terrain, Start, -y, Norm); #if (vlength(Norm) != 0) #if (rand(Wrd) < 0.2) #declare j = 0; #declare Start0 = Start; #while (j < 20+rand(Wrd)*20) #if (rand(Wrd) < 0.5) // lines of trees #declare Dir = *(1+rand(Wrd))*4; #declare Start = Start+Dir; #else // groves and thickets #declare Start = vaxis_rotate((1+rand(Wrd))*20, y, 360*rand(Wrd))+Start0; #end #declare Norm = <0,0,0>; #declare Inter = trace (Terrain, Start, -y, Norm); #if (vlength(Norm) != 0) #if (Typ = 0) object {WildTree(Trd) translate Inter} #else object {Tree(Trd) translate Inter} #end //cylinder {0, <0, 10, 0>, 0.2 pigment {rgb <0.8, 0.5, 0.4>} translate Inter} //treetrunk. Should be replaced by something better!! #end #declare j = j+1; #end //of while #else // single tree #if (Typ = 0) object {WildTree(Trd) translate Inter} #else object {Tree(Trd) translate Inter} #end //cylinder {0, <0, 10, 0>, 0.2 pigment {rgb <0.8, 0.5, 0.4>} translate Inter} //treetrunk. Should be replaced by something better!! #end #end #declare i = i+1; #end } Terrain Woods #end //of CamLoc