// Ghurghusht and the Shams System // (C) 2010-20?? Jörg "Yadgar" Bleimann // Credits: // Atmosphere: Bruno Cabasson // Water: Christoph Hormann #include "functions.inc" #declare ani=0; // animation flag (if mapping = 0) #declare mapping=0; // toggles generating a cylindrical map of Ghurghusht, 2 = altitude probing mode #declare greymap=3; // 0 = physical map, 1 = 8-bit grayscale map, 2 = 16-bit grayscale map, 3 = 24-bit map #declare legend=0; // toggles rendering map legend only (if mapping != 0) #declare ridges=2; // switches between various patterns for isosurface #declare os=0; // operating system: 0 = Linux, 1 = Windows #declare tcm=0; // terrain calculation mode: 0 = isosurface, 1 = mesh2 #declare test=0; // 0 = full globe, 1 = lake around Sitara Insula only // begin modifications according to Bruno Cabasson's TerraPOV tutorial (2009) #if (ani=1) #declare mapping=0; #end #if (mapping=2) #declare greymap=1; #end global_settings { #if (version < 3.7) assumed_gamma 1 #end max_trace_level 20 } #declare TP_PLANET_RADIUS = 5124.6666; #declare TP_BASE_RAYLEIGH_POWER = 6.7; // Constant #declare TP_RAYLEIGH_FACTOR = 0.5; // User defined #declare _tp_rayleigh_power = TP_BASE_RAYLEIGH_POWER*TP_RAYLEIGH_FACTOR; #declare TP_ATMO_THICKNESS = 50; #declare TP_RAYLEIGH_DENSITY_MAX = 1; #declare TP_RAYLEIGH_AMOUNT = 2.3; #declare _tp_rayleigh_density = density { function { TP_RAYLEIGH_DENSITY_MAX*exp(-_tp_rayleigh_power*(sqrt(x*x+(y+TP_PLANET_RADIUS)*(y+TP_PLANET_RADIUS)+z*z) - TP_PLANET_RADIUS)/TP_ATMO_THICKNESS) } } #declare TP_RAYLEIGH_SCATTERING_COLOR = rgb <0.135, 0.33, 1>; #declare TP_ATMO_INTERVALS = 3; // Necessary for good integration #declare TP_ATMO_SAMPLES = 3; #declare TP_ATMO_METHOD = 3; // Adaptive #declare TP_ATMO_BOTTOM = 0; #declare _tp_rayleigh_media = media { method TP_ATMO_METHOD intervals TP_ATMO_INTERVALS samples TP_ATMO_SAMPLES scattering { 4, TP_RAYLEIGH_AMOUNT*TP_RAYLEIGH_SCATTERING_COLOR/TP_ATMO_THICKNESS extinction 1 } density { _tp_rayleigh_density } } #declare _tp_rayleigh_atmosphere = difference { sphere {0, TP_PLANET_RADIUS + TP_ATMO_BOTTOM + TP_ATMO_THICKNESS translate -TP_PLANET_RADIUS*y} sphere {0, TP_PLANET_RADIUS + TP_ATMO_BOTTOM translate -TP_PLANET_RADIUS*y} hollow pigment {rgbt 1} interior {media{_tp_rayleigh_media}} translate TP_PLANET_RADIUS*y } // end modifications according to Bruno Cabasson's TerraPOV tutorial (2009) #if (os=0) #declare fontpath="/media/disk1part9/fonts/"; #else #declare fontpath="D:/WINDOWS/Fonts/"; #end #if (greymap=2) global_settings { hf_gray_16 } #end #declare S = function { x*x + y*y + z*z -1 } #declare Terrain_Part1_Function= function { pattern { granite scale 10 poly_wave 0.333 } } #declare Terrain_Part2_Function= function { pattern { bozo } } #declare Terrain_Part3_Function= function { pattern { ripples scale 10 turbulence 0.5 } } #declare P_Average = pigment { average pigment_map { [0.5 granite scale 10 poly_wave 0.333 ] [1 spherical scale 10 turbulence 0.5 poly_wave 0.333 ] [0.025 crackle scale 0.2 turbulence 1 ] } } #declare Terrain_Part4_Function= function { pigment { P_Average } } #switch (ridges) #case (0) #declare Terrain_Function= function { S(x, y, z) + Terrain_Part1_Function (x*50, y*50, z*50)*0.02 + Terrain_Part2_Function (x, y, z)*0.01 } #break #case (1) #declare Terrain_Function= function { S(x, y, z) + Terrain_Part3_Function (x*50, y*50, z*50)*0.05 + Terrain_Part2_Function (x, y, z)*0.01 } #break #case (2) #declare Terrain_Function= function { S(x, y, z) + Terrain_Part4_Function (x*50, y*50, z*50).gray*0.05 + Terrain_Part2_Function (x, y, z)*0.01 } #break #end #if (!mapping) union { sphere // Qais { 0, 1 texture { pigment { color rgb <0, 0.3, 1> } finish { ambient 0.05 diffuse 1 brilliance 0.4 } } } difference { cylinder { <0, -0.002, 0>, <0, 0.002, 0>, 2.4 } cylinder { <0, -0.0021, 0>, <0, 0.0021, 0>, 1.5 } double_illuminate texture { pigment { cylindrical color_map { [0 rgbf <1, 0.97, 0.985, 0.6>] [0.09 rgbf <1, 0.97, 0.985, 0.6>] [0.09 rgbf <0.2, 0.14, 0.04, 0.045>] [0.1023 rgbf <0.5, 0.34, 0.14, 0.045>] [0.1023 rgbf <1, 0.95, 0.94, 0.5>] } scale 2.4 } finish { ambient 0.05 diffuse 1 brilliance 0.2 } } } scale <59382, 53401, 59382> rotate <-8.6, 0, 27.7> } #if (!ani) #declare Pos_Ghurghusht = 570000 * ; #else #declare Pos_Ghurghusht = 570000 * ; #end light_source // Shams { <-104720000, 0, 0> color rgb <1, 1, 0.95> } sphere { (<-104720000, 0, 0>-Pos_Ghurghusht)/100, 6230 texture { pigment { color rgb <1, 1, 0.95> } finish { ambient 1 diffuse 0 } } no_shadow } #end #declare T_Ghurghusht= texture { pigment { color rgb <0.98, 0.85, 0.45> } finish { ambient 0.05 diffuse 1 brilliance 0.98 } } #if (tcm=0) #declare Ghurghusht = isosurface { function { Terrain_Function(x, y, z) } contained_by { sphere { 0, 1 } } max_gradient 5 accuracy 0.0001 double_illuminate texture { T_Ghurghusht } scale 5178 } #else #declare hf= pigment { image_map { png "tiles/ghurghusht360_n05_040.png" } } #declare sl=5124.6666; #declare rng=31.5519+6.2452; #declare ll=sl-6.2452; #declare long=40; #declare lat=5; #declare Ghurghusht = mesh2 { vertex_vectors { 1440000 // 1200 * 1200 #declare a=0; #while (a<1200) #declare b=0; #while (b<1200) #declare rd=eval_pigment(hf, <1/2400+b/1200, 2399/2400-a/1200, 0>).red; #declare gr=eval_pigment(hf, <1/2400+b/1200, 2399/2400-a/1200, 0>).green/256; #declare bl=eval_pigment(hf, <1/2400+b/1200, 2399/2400-a/1200, 0>).blue/65536; (ll+(rd+gr+bl)*rng)* #declare b=b+1; #end // #warning concat("Assigning vectors for line ", str(a, 4, 0)) #declare a=a+1; #end } face_indices { 2875202 // 1199 * 1199 * 2 #declare a = 0; #while (a < 1199) #declare b = 0; #while (b < 1199) <1200*a + b, 1200*a + b+1, 1200*(a+1) + b>, <1200*a + b+1, 1200*(a+1) + b+1, 1200*(a+1) + b> #if(b<(l-2)) , #end #declare b = b+1; #end #warning concat("Parsing lines ", str(a, 4, 0), " and ", str(a+1, 4, 0),".") #declare a = a+1; #end } texture { T_Ghurghusht } } #end #if (!mapping) #declare Box_Cutout = box { <-1, -10, -1>, <1, 30, 1> #declare surfPos = trace(Ghurghusht, 0, ); rotate <0, 0, 90-0.368888888> rotate <0, -50.5905556, 0> translate surfPos } union { #if (test = 1) intersection { union { #end object { Ghurghusht } sphere { 0, 1 material { texture { pigment { color rgbt <1, 1, 1, 1> } finish { diffuse 0 reflection { <0.03, 0.03, 0.04>, <0.75, 0.75, 1> exponent 1.2 falloff 5 fresnel on } phong 1 phong_size 2500000 } normal { bozo 1.5 bump_size 0.5 scale 0.00000013 } } interior { ior 1.34 } } scale 5178*0.9897 // sea level at 5124.6666 kms } sphere { 0, 1 hollow texture { pigment { color rgb <0, 0, 0.5> } finish { ambient 0.05 diffuse 1 brilliance 1 } } scale 5178*0.98969999 // preliminary sea floor at 5124.666548 kms } #if (test = 1) } object { Box_Cutout } bounded_by { object { Box_Cutout } } } #end #if (test = 0) object { _tp_rayleigh_atmosphere } #end #if (ani=1) rotate y*(clock/10) #end translate Pos_Ghurghusht } #if (test = 1) sky_sphere { pigment { gradient y color_map { [0 rgb <0.8, 1, 1>] [0.15 rgb <0, 0.7, 1>] [0.3 rgb <0, 0.3, 1>] [1 rgb <0, 0.3, 1>] } rotate <0, 0, 90-0.368888888> rotate <0, -50.5905556, 0> } } #end #declare view=15; #if (test=1) #declare view=12; #end #switch (view) #case (0) #declare camPos=Pos_Ghurghusht + 20000 * ; #declare camLook=Pos_Ghurghusht-<7200, 0, 0>; #declare camAng=1.5; #declare surfPos=<-1, 0, 0>; #break #case (1) #declare camPos=Pos_Ghurghusht + 20000 * ; #declare camLook=Pos_Ghurghusht; #declare camAng=40; #declare surfPos=<0, 1, 0>; #break #case (2) #declare lat=0.131666666; #declare long=140.902222; #declare ht=3000; #declare dir=0; #declare azi=-89.999; #declare camAng=40; #break #case (3) // equivalent to Cologne, Germany #declare lat=51; #declare long=7; #declare ht=1000; #declare dir=0; #declare azi=-89.999; #declare camAng=40; #break #case (3.01) // equivalent to Cologne, Germany #declare lat=51; #declare long=7; #declare ht=250; #declare dir=0; #declare azi=-89.999; #declare camAng=40; #break #case (3.02) // equivalent to Cologne, Germany #declare lat=51; #declare long=7; #declare ht=50; #declare dir=0; #declare azi=-89.999; #declare camAng=40; #break #case (4) // equivalent to Kabul, Afghanistan #declare lat=34.5; #declare long=67.75; #declare ht=0.0017; #declare dir=0; #declare azi=0; #declare camAng=40; #break #case (5) // Centlivres Lacus #declare lat=-33.54; #declare long=110.78; #declare ht=0.0017; #declare dir=0; #declare azi=0; #declare camAng=40; #break #case (6) // substellar point #declare lat=0; #declare long=90; #declare ht=20000; #declare dir=0; #declare azi=-89.999; #declare camAng=40; #break #case (7) // 45 degrees west from substellar point #declare lat=0; #declare long=45; #declare ht=0.0017; #declare dir=90; #declare azi=45; #declare camAng=40; #break #case (8) // 55 degrees west from substellar point #declare lat=0; #declare long=35; #declare ht=0.0017; #declare dir=90; #declare azi=35; #declare camAng=40; #break #case (9) // 65 degrees west from substellar point #declare lat=0; #declare long=25; #declare ht=0.0017; #declare dir=90; #declare azi=25; #declare camAng=40; #break #case (10) // 80 degrees west from substellar point #declare lat=0; #declare long=10; #declare ht=0.05; #declare dir=90; #declare azi=10; #declare camAng=40; #break #case (11) // 90 degrees west from substellar point #declare lat=0; #declare long=0; #declare ht=5; #declare dir=90; #declare azi=0; #declare camAng=40; #break #case (12) // Schmidt Lacus, Achakzai Peninsula #declare lat=0.368888888; #declare long=140.5905556; #declare ht=0.5; #declare dir=135; #declare azi=-37; #declare camAng=40; #break #case (13) // 90 degrees east from substellar point #declare lat=0; #declare long=180; #declare ht=0.5; #declare dir=270; #declare azi=0; #declare camAng=40; #break #case (14) // Test scene for isosurface vs. mesh2 comparison #declare lat=1.8; #declare long=43.2; #declare ht=0.0017; #declare dir=315; #declare azi=0; #declare camAng=40; #break #case (15) // Rathjens Lacus #declare lat=17; #declare long=27.8; #declare ht=0.0017; #declare dir=90; #declare azi=0; #declare camAng=40; #break #end #if (view=0 | view=1) camera { #if (ani=1) sky <-1, 0, 0> #else sky surfPos #end location camPos look_at camLook angle camAng } #else camera { #declare surfPos = trace(Ghurghusht, 0, ); #if (vlength(surfPos)<5178*0.9897) #declare surfPos = vnormalize(surfPos)*5178*0.9897; // camera over lake #end #declare camPos = Pos_Ghurghusht + surfPos + vnormalize(surfPos)*ht; #declare dirVect = ; #declare camLook=camPos + vrotate(dirVect, ); sky surfPos location camPos look_at camLook angle camAng } #end #else #declare T_White = texture { pigment { color rgb 1 } finish { ambient 1 diffuse 0 } } #declare Grid_Bar_H = box { 0, <15, 1, 3> texture { T_White } } #declare Grid_Bar_V = object { Grid_Bar_H rotate <0, -90, 0> translate <2, 0, 0> } #declare Physical = array[26] { color rgb <0, 0, 0.2>, color rgb <0, 0, 0.4>, color rgb <0, 0, 0.7>, color rgb <0, 0.15, 1>, color rgb <0, 0.25, 1>, color rgb <0, 0.5, 1>, color rgb <0, 0.65, 1>, color rgb <0, 1, 1>, color rgb <0.4, 1, 1>, color rgb <0.6, 1, 1>, color rgb <0, 0.7, 0>, color rgb <0, 1, 0>, color rgb <1, 1, 0.5>, color rgb <1, 1, 0>, color rgb <1, 0.7, 0>, color rgb <1, 0.6, 0>, color rgb <1, 0.4, 0>, color rgb <1, 0.2, 0>, color rgb <1, 0, 0>, color rgb 0.3, color rgb 0.4, color rgb 0.5, color rgb 0.6, color rgb 0.7, color rgb 0.78, color rgb 1 }; #declare Elevations = array [25] { "10000", "8000", "6000", "4000", "2000", "1000", "500", "200", "100", "0", "100", "200", "500", "1000", "2000", "3000", "4000", "5000", "6000", "7000", "8000", "10000", "12000", "15000", "20000" }; #declare lat_start=5; #declare long_start=40; #declare res=360; // pixels per degree #declare xdim=1200; #declare ydim=1200; #declare lat_end=lat_start-(ydim/res); #declare long_end=long_start+(xdim/res); #if (!legend) #declare sl=5124.6666; // sea level #if (mapping=2) // elevation probing mode for grayscale maps #declare min_file=0; #declare max_file=0; #declare lat_start=90-int(clock/72)*5; #declare long_start=mod(clock, 72)*5; #declare lat_end=lat_start-(ydim/res); #declare long_end=long_start+(xdim/res); #fopen mm "minmax" read #while (defined(mm)) #read (mm, min_file, max_file) #end #fclose mm #warning concat("min_file = ", str(min_file, 5, 4), " max_file = ", str(max_file, 5, 4)) #declare min_el=min_file; #declare max_el=max_file; #end #declare lat=lat_start; #while (lat >= lat_end) #declare long=long_start; #while (long < long_end) #declare el=vlength(trace(Ghurghusht, 0, )); #if (greymap=0) // defining pixel colors for physical map #switch(el-sl) #range (-sl, -10) #declare pc = Physical[0]; #break #range (-10, -8) #declare pc = Physical[1]; #break #range (-8, -6) #declare pc = Physical[2]; #break #range (-6, -4) #declare pc = Physical[3]; #break #range (-4, -2) #declare pc = Physical[4]; #break #range (-2, -1) #declare pc = Physical[5]; #break #range (-1, -0.5) #declare pc = Physical[6]; #break #range (-0.5, -0.2) #declare pc = Physical[7]; #break #range (-0.2, -0.1) #declare pc = Physical[8]; #break #range (-0.1, 0) #declare pc = Physical[9]; #break #range (0, 0.1) #declare pc = Physical[10]; #break #range (0.1, 0.2) #declare pc = Physical[11]; #break #range (0.2, 0.5) #declare pc = Physical[12]; #break #range (0.5, 1) #declare pc = Physical[13]; #break #declare (1, 2) #declare pc = Physical[14]; #break #range (2, 3) #declare pc = Physical[15]; #break #range (3, 4) #declare pc = Physical[16]; #break #range (4, 5) #declare pc = Physical[17]; #break #range (5, 6) #declare pc = Physical[18]; #break #range (6, 7) #declare pc = Physical[19]; #break #range (7, 8) #declare pc = Physical[20]; #break #range (8, 10) #declare pc = Physical[21]; #break #range (10, 12) #declare pc = Physical[22]; #break #range (12, 15) #declare pc = Physical[23]; #break #range (15, 20) #declare pc = Physical[24]; #break #range (20, 100) #declare pc = Physical[25]; #break #end #else #if (mapping=2) // probing for lowest and highest elevation #if ((el-sl)max_el) #declare max_el = el-sl; #end #end #declare rng=31.5519+6.2452; #declare ll=sl-6.2452; #declare grv=(el-ll)/rng; #end #if (mapping != 2) box { 0, 1 texture { #switch (greymap) #case (0) // physical map pigment { color rgb } #break #case (1) // 8-bit heightfield pigment { color rgb } #break #case (2) // 16-bit heightfield #break #case (3) // 24-bit heightfield #declare rdraw = grv*255; #declare rdval = int(rdraw); #declare grraw = (rdraw-rdval)*255; #declare grval = int(grraw); #declare blraw = (grraw-grval)*255; #declare blval = int(blraw); pigment { color rgb /255 } #break #end finish { ambient 1 diffuse 0 } } translate <(long-long_start)*res, 0, 450-(lat_start-lat)*res> } #end #declare long=long+1/res; #end #declare lat=lat-1/res; #end #end #if (mapping=2) #warning concat("min_el = ", str(min_el, 5, 4), " max_el = ", str(max_el, 5, 4)) #fopen mm "minmax" write #write (mm, min_el, ",", max_el, "\n") #fclose mm #end #if(legend) box // dummy map { <0, 0, -450>, <1800, 1, 450> texture { pigment { color rgb <1, 0, 0> } finish { ambient 1 diffuse 0 } } } #end #if (greymap=0) object { Grid_Bar_H translate <-15, 0, -450> } // lower left map corner, latitude bar object { Grid_Bar_H translate <-15, 0, 447> } // upper left map corner, latitude bar object { Grid_Bar_H translate <1800, 0, -450> } // lower right map corner, latitude bar object { Grid_Bar_H translate <1800, 0, 447> } // upper right map corner, latitude bar object { Grid_Bar_V translate <1, 0, -465> } // lower left map corner, longitude bar object { Grid_Bar_V translate <1, 0, 450> } // upper left map corner, longitude bar object { Grid_Bar_V translate <1798, 0, -465> } // lower right map corner, longitude bar object { Grid_Bar_V translate <1798, 0, 450> } // upper right map corner, longitude bar text { ttf concat(fontpath, "arial.ttf") str(lat_start, 2, 0), 1, 0 texture { T_White } rotate <90, 0, 0> scale 20 translate <-47, 0, 442.5> } text { ttf concat(fontpath, "arial.ttf") str(lat_end, 2, 0), 1, 0 texture { T_White } rotate <90, 0, 0> scale 20 translate <-47, 0, -455> } text { ttf concat(fontpath, "arial.ttf") str(lat_start, 2, 0), 1, 0 texture { T_White } rotate <90, 0, 0> scale 20 translate <1820, 0, 442.5> } text { ttf concat(fontpath, "arial.ttf") str(lat_end, 2, 0), 1, 0 texture { T_White } rotate <90, 0, 0> scale 20 translate <1820, 0, -455> } text { ttf concat(fontpath, "arial.ttf") str(long_end, 3, 0), 1, 0 texture { T_White } rotate <90, 0, 0> scale 20 translate <1785, 0, 470> } text { ttf concat(fontpath, "arial.ttf") str(long_start, 3, 0), 1, 0 texture { T_White } rotate <90, 0, 0> scale 20 translate <-15, 0, 470> } text { ttf concat(fontpath, "arial.ttf") str(long_end, 3, 0), 1, 0 texture { T_White } rotate <90, 0, 0> scale 20 translate <1785, 0, -484> } text { ttf concat(fontpath, "arial.ttf") str(long_start, 3, 0), 1, 0 texture { T_White } rotate <90, 0, 0> scale 20 translate <-15, 0, -484> } text { ttf concat(fontpath, "arial.ttf") concat("Cylindrical Map of Ghurghusht - ", str(res, 3, 0), " pixels per degree"), 1, 0 texture { pigment { color rgb 1 } finish { ambient 1 diffuse 0 } } rotate x*90 scale 40 translate <430, 0, 515> } #declare Elevation_Color_Bar = box { 0, <40, 1, 20> } #declare a=0; #while (a<26) object { Elevation_Color_Bar texture { pigment { color rgb } finish { ambient 1 diffuse 0 } } translate <40*a, 0, -525> } #declare a=a+1; #end #declare a=0; #while (a<25) text { ttf concat(fontpath, "arial.ttf") Elevations[a] 1, 0 texture { pigment { color rgb 1 } finish { ambient 1 diffuse 0 } } rotate x*90 scale 10 #if (a=9) #declare os=7.5; #else #declare os=6; #end translate <5*(os+8*a), 0, -540> } #declare a=a+1; #end text { ttf concat(fontpath, "arial.ttf") "Depths and elevations in metres" 1, 0 texture { pigment { color rgb 1 } finish { ambient 1 diffuse 0 } } rotate x*90 scale 10 translate <1090, 0, -540> } #end camera { orthographic #switch (greymap) #case (0) // physical map with legend right <1900, 0, 0> up <0, 1100, 0 > location <900, 500, 0> look_at <900, 0, 0> #break #range (1, 2) // 8- and 16-bit heightfield, global coverage right <1800, 0, 0> up <0, 900, 0> location <900, 500, 0> look_at <900, 0, 0> #break #case (3) // tiled 24-bit heightfields right <1200, 0, 0> up <0, 1200, 0> location <600, 500, -150> look_at <600, 0, -150> #break #end } #end