// Persistence of Vision Ray Tracer Scene Description File // File: menger_sphere.pov // Vers: 3.5 // Desc: Menger's sponge stuff // Date: 16/08/2003 // Auth: Jean-Charles Marteau // #version 3.5; #declare With_Main_Light=on; #declare With_Fill_Light=on; #declare With_Back_Light=on; #declare With_Focal_Blur=off; global_settings { assumed_gamma 1.0 //hf_gray_16 //max_trace_level 25 } #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> #if (With_Focal_Blur) aperture 0.1 // [0...N] larger is narrower depth of field (blurrier) blur_samples 4 // number of rays per pixel for sampling focal_point <0,0.5,0> // point that is in focus confidence 0.9 // [0...1] when to move on while sampling (smaller is less accurate) variance 1/128 // [0...1] how precise to calculate (smaller is more accurate) #end angle 18 } // 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) 6, 6 // 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 } #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 // ---------------------------------------- sphere { 0, 100 texture { pigment { rgb <0,0,1> } finish { ambient 1.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 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.4, 0.4 } // - 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,6), "\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/3 } #end #end #local MySeed=seed(5); 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 (4, box { -0.4, 0.4 }, 3, 1.0, MySeed) // A basic texture 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 //metallic 1.0 } conserve_energy } normal { wood turbulence 0.3 scale 0.04 bump_size 0.05 } } translate 0.5*y }