/* -------------------------- Entry: 0014 WWW: http://exether.free.fr/irtc Title: Kheops Author: Jean-Charles Marteau ---------------------------*/ // Persistence of Vision Ray Tracer Scene Description File // File: menger_sphere.pov // Vers: 3.5 // Desc: Menger's sponge stuff and other fractal // Date: 16/08/2003 // Modified for Fractal contest 10/04/2004 #version 3.5; #declare With_Main_Light=on; #declare With_Fill_Light=on; #declare With_Back_Light=on; #declare With_Focal_Blur=off; #declare Photons=off; #declare Radiosity=off; global_settings { assumed_gamma 1.0 max_trace_level 60 #if (Radiosity) radiosity { pretrace_start 0.08 pretrace_end 0.0025 count 500 nearest_count 5 // pretrace_end 0.02 count 50 nearest_count 3 error_bound 0.6 // higher -> smoother, less accurate [1.8] recursion_limit 2 // how much interreflections are calculated (1..5+) [3] low_error_factor .5 // reduce error_bound during last pretrace step gray_threshold 0.3 // increase for weakening colors (0..1) [0] minimum_reuse 0.015 // reuse of old radiosity samples [0.015] brightness 5 // 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] //save_file "hexa_grid_rad.rad" //load_file "hexa_grid_rad.rad" //always_sample off // turn sampling in final trace off [on] //max_sample 1.0 // maximum brightness of samples } #end #if (Photons) photons { spacing 0.02 // specify the density of photons //count 100000 // alternatively use a total number of photons //gather min, max // amount of photons gathered during render [20, 100] //media max_steps [,factor] // media photons //jitter 1.0 // jitter phor photon rays //max_trace_level 5 // optional separate max_trace_level //adc_bailout 1/255 // see global adc_bailout //save_file "menger_2_2.photons" // save photons to file //load_file "menger_2_2.photons" // load photons from file //autostop 0 // photon autostop option //radius 10 // manually specified search radius // (---Adaptive Search Radius---) //steps 1 //expand_thresholds 0.2, 40 } #end } // ---------------------------------------- #default { texture { pigment {rgb 1} finish { ambient 0.0 diffuse 0.6 specular 0.3 } } } // ---------------------------------------- camera { right x*image_width/image_height //location <1.3,1.6,-4>*2 look_at <0.4,0.5,0> angle 18 location <1.3,3.6,-4>*0.4 look_at <0.0,0.3,0> angle 56 #if (With_Focal_Blur) aperture 0.1 blur_samples 4 focal_point <0,0.5,0> confidence 0.9 variance 1/128 #end } #if (!Radiosity) // Classical photographic three-points light #if (With_Main_Light) light_source { <-30,40,-20> // light's position color rgb <1, 1, 1> // light's color area_light <2, 0, 0> <0, 0, 2> // lights spread out across this distance (x * z) 2, 2 // total number of lights in grid (4x*4z = 16 lights) adaptive 0 // 0,1,2,3... jitter // adds random softening of light circular // make the shape of the light circular orient // orient light fade_distance 50 fade_power 2 photons { // photon block for a light source refraction on reflection on } } #end #if (With_Fill_Light) light_source { <20,10,-40> // light's position color rgb <1, 1, 1>/3 // light's color area_light <8, 0, 0> <0, 0, 8> // lights spread out across this distance (x * z) 2, 2 // total number of lights in grid (4x*4z = 16 lights) adaptive 0 // 0,1,2,3... jitter // adds random softening of light circular // make the shape of the light circular orient // orient light } #end #if (With_Back_Light) light_source { <10,0.1,40> // light's position color rgb <1, 1, 1> // light's color area_light <8, 0, 0> <0, 0, 8> // lights spread out across this distance (x * z) 2, 2 // total number of lights in grid (4x*4z = 16 lights) adaptive 0 // 0,1,2,3... jitter // adds random softening of light circular // make the shape of the light circular orient // orient light } #end #else sphere { <-3,4,-2>, 1 texture { pigment { rgb <1,0.5,0.0> } finish { ambient 10 } } } #end // ---------------------------------------- // A basic texture #declare T_Plastic = texture { pigment { rgb 0.5 } finish { ambient 0 phong 0.4 phong_size 3 reflection { 0.2 fresnel on falloff 1.0 exponent 1.0 } conserve_energy } normal { wood turbulence 0.3 scale 0.04 bump_size 0.05 } } // ---------------------------------------- sphere { 0, 100 texture { pigment { rgb <0,0,1> } finish { ambient 0.0 } } hollow } plane { y, 0 texture { pigment { rgb 1 } normal { granite scale 0.05 } } } #declare Neighbours = array[20] { // haut <-1, 1,-1>, < 0, 1,-1>, < 1, 1,-1>, <-1, 1, 0>, < 1, 1, 0>, <-1, 1, 1>, < 0, 1, 1>, < 1, 1, 1>, // milieu <-1, 0,-1>, < 1, 0,-1>, <-1, 0, 1>, < 1, 0, 1>, // bas <-1,-1,-1>, < 0,-1,-1>, < 1,-1,-1>, <-1,-1, 0>, < 1,-1, 0>, <-1,-1, 1>, < 0,-1, 1>, < 1,-1, 1> } #declare Neighbours = array[5] { <0,1,0>, <1/sqrt(2),0,1/sqrt(2)>, <-1/sqrt(2),0,1/sqrt(2)>, <1/sqrt(2),0,-1/sqrt(2)>, <-1/sqrt(2),0,-1/sqrt(2)> } #declare Nb_objects=0; // Creates a menger sponge made of any objects. // - Level is the max level of recursion the fractal will go to. // - Obj is the object the sponge will be made of, it should fit in box { -0.5, 0.5 } // - Turb is the fractal level turbulence, if positive, the result will have various levels // of recursion choosen in a random way ( 0 <= Turb ~< Level ) . // - Filling, it is the probability that a sub-object will be present ( 0.0 < Filling <= 1.0 ) // - Random seed used if Turb <> 0 or Filling < 1.0 // Number of objects increases when you increase Level or Filling, it decreases // when you increase Turb. #macro Menger_Sponge (Level, Obj, Turb, Filling, TheSeed) #if (Level <= 0) #declare Nb_objects = Nb_objects + 1; object { Obj } #if (mod(Nb_objects,10000) = 0) #debug concat ("Number of objects = ", str (Nb_objects,0,0), "\n") #end #else union { #local i = 0; #while (i < dimension_size (Neighbours, 1)) #if (rand(MySeed) < Filling) object { Menger_Sponge (Level-(1+floor(Turb*rand(MySeed))), Obj, Turb, Filling, TheSeed) translate Neighbours[i] } #end #local i = i + 1; #end scale 1/2 // scale 1/3 } #end #end #local MySeed=seed(7); object { #declare Nb_objects=0; // OK with 1Go of mem //Menger_Sponge (6, sphere { 0, 0.5 }, 3, 1.0, MySeed) //Menger_Sponge (4, sphere { 0, 0.5 }, 0, 1.0, MySeed) //Menger_Sponge (6, box { -0.4, 0.4 }, 3, 1.0, MySeed) // OK with 256Mo of mem //Menger_Sponge (5, sphere { 0, 0.5 }, 3, 0.7, MySeed) //Menger_Sponge (3, sphere { 0, 0.5 }, 0, 0.8, MySeed) //Menger_Sponge (4, sphere { 0, 0.5 }, 3, 1.0, MySeed) //Menger_Sponge (2, sphere { 0, 0.5 }, 2, 1.0, MySeed) //Menger_Sponge (4, box { -0.4, 0.4 }, 3, 1.0, MySeed) // Pyramids //Menger_Sponge (5, sphere { <0,0.5,0>, 0.5 }, 2, 1.0, MySeed) //Menger_Sponge (10, sphere { <0,0.5,0>, 0.5 }, 2, 1.0, MySeed) Menger_Sponge (8, sphere { <0,0.6,0>, 0.6 }, 2, 1.0, MySeed) /* material { M_Glass } photons { target 1.0 refraction on reflection on } */ texture { T_Plastic } // translate 0.5*y }