// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 ======= 10 /* "Towards Tek's Isosurface City" by Tor Olav Kristensen, December 2023 http://subube.com https://github.com/t-o-k */ // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 ======= 10 #version 3.7; global_settings { assumed_gamma 1.0 radiosity { pretrace_start 0.08 // start pretrace at this size pretrace_end 0.04 // end pretrace at this size count 35 // higher -> higher quality (1..1600) nearest_count 5 // higher -> higher quality (1..10) error_bound 1.8 // higher -> smoother, less accurate recursion_limit 3 // how much interreflections are calculated (1..5+) low_error_factor 0.5 // reduce error_bound during last pretrace step gray_threshold 0.0 // increase for weakening colors (0..1) minimum_reuse 0.015 // reuse of old radiosity samples brightness 1.0 // brightness of radiosity effects (0..1) adc_bailout 0.005 // normal on // take surface normals into account // media on // take media into account // save_file "file_name" // save radiosity data // load_file "file_name" // load saved radiosity data // always_sample off // turn sampling in final trace off // max_sample 1.0 // maximum brightness of samples } } default { texture { pigment { color rgb <1, 1, 1> } finish { ambient color rgb <0, 0, 0> diffuse 0.6 specular 0.3 } } } // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 ======= 10 #declare GroundFn = function { pattern { crackle metric 1 form <-1, +1, 0> } } ; #declare BuildingsFn = function { pattern { crackle metric 1 form <-1, 0, +1> } } ; #declare Heights = array[9] { -0.010, // 0 // Roads -0.005, // 1 // Pavements -0.001, // 2 // Grass 0.000, // 3 // Bases of buldings & Tunnels +0.050, // 4 // Bases of buldings +0.100, // 5 // Buildings +0.300, // 6 // Tops of buildings +0.600, // 7 // Roofs of buildings +0.610 // 8 } ; #declare BuildingsPigment = pigment { function { min( 1.0, max( abs(2*mod(abs(x) + 0.5, 1.0) - 1.0), abs(2*mod(abs(y) + 0.5, 1.0) - 1.0), abs(2*mod(abs(z) + 0.5, 1.0) - 1.0) ) ) } color_map { [ 0.5 color rgb <0, 0, 0> ] [ 0.5 color rgb <1, 1, 1> ] } translate 0.5*y scale <1/sqrt(2), 1, 1/sqrt(2)>/40 rotate 45/2*y } #declare StripesInRoadsPigment = pigment { color rgb <1.0, 1.0, 1.0> } #declare RoadsPigment = pigment { color rgb <0.1, 0.1, 0.1> } #declare PavementsPigment = pigment { color rgb <0.4, 0.4, 0.4> } #declare GrassPigment = pigment { color rgb <0.0, 0.7, 0.1> } #declare RoofsPigment = pigment { color rgb <0.8, 0.8, 0.8> } #declare H = 0.35; // Sample height in patterns #declare S = 20; // Side lengths of rendered area #declare Accuracy = 1e-5; #declare MaxGradient = 2.6; // Stripes in roads isosurface { function { GroundFn(x, H, z) - 1.00 } threshold -0.990 contained_by { box { <-S, Heights[0], -S>, <+S, Heights[1], +S> } } max_gradient MaxGradient accuracy Accuracy pigment { StripesInRoadsPigment } } // Roads isosurface { function { 1.00 - GroundFn(x, H, z) } threshold +0.990 contained_by { box { <-S, Heights[0], -S>, <+S, Heights[1], +S> } } max_gradient MaxGradient accuracy Accuracy pigment { RoadsPigment } } // Pavements isosurface { function { 1.00 - GroundFn(x, H, z) } threshold +0.900 contained_by { box { <-S, Heights[1], -S>, <+S, Heights[2], +S> } } max_gradient MaxGradient accuracy Accuracy pigment { PavementsPigment } } // Grass isosurface { function { 1.00 - GroundFn(x, H, z) } threshold +0.800 contained_by { box { <-S, Heights[2], -S>, <+S, Heights[3], +S> } } max_gradient MaxGradient accuracy Accuracy pigment { GrassPigment } } // Bases of buildings with tunnels difference { isosurface { function { 1.00 - BuildingsFn(x, H, z) } threshold +0.500 contained_by { box { <-S, Heights[3], -S>, <+S, Heights[5], +S> } } max_gradient MaxGradient accuracy Accuracy } isosurface { function { GroundFn(x, H, z) - 1.00 } threshold -0.900 // + 0.100 contained_by { box { <-S, Heights[0], -S>, <+S, Heights[4], +S> } } max_gradient MaxGradient accuracy Accuracy } pigment { BuildingsPigment } } // Buildings isosurface { function { 1.00 - BuildingsFn(x, H, z) } threshold +0.250 contained_by { box { <-S, Heights[5], -S>, <+S, Heights[6], +S> } } max_gradient MaxGradient accuracy Accuracy pigment { BuildingsPigment } } // Tops of buildings isosurface { function { 1.00 - BuildingsFn(x, H, z) } threshold +0.080 contained_by { box { <-S, Heights[6], -S>, <+S, Heights[7], +S> } } max_gradient MaxGradient accuracy Accuracy pigment { BuildingsPigment } } // Roofs of buildings isosurface { function { 1.00 - BuildingsFn(x, H, z) } threshold +0.001 contained_by { box { <-S, Heights[7], -S>, <+S, Heights[8], +S> } } max_gradient MaxGradient accuracy Accuracy pigment { RoofsPigment } } // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 ======= 10 sky_sphere { pigment { gradient y color_map { [ 0.0 rgb <0.0, 0.0, 0.0> ] [ 0.6 rgb <1.0, 0.9, 0.8> ] [ 0.8 rgb <0.6, 0.7, 0.8> ] } scale 2*<1, 1, 1> translate y } } light_source { 1000*<-4, +5, -1> color rgb 0.9*<1, 1, 1> } camera { location 1.4*<+3, +2, -4> look_at < 0, -2, 0> } // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 ======= 10