POV-Ray : Newsgroups : povray.binaries.images : POVEarth: I just don't get it... : POVEarth: I just don't get it... Server Time
30 Jul 2024 00:17:30 EDT (-0400)
  POVEarth: I just don't get it...  
From: Jörg 'Yadgar' Bleimann
Date: 28 Jun 2013 17:40:17
Message: <51ce02c1@news.povray.org>
Hi(gh)!

After a longer retreat from active POVing (and, instead, collecting 
elevation data for my POVEarth project), I started to generate 
heightfields from ASTER GeoTIFFs (3601 x 3601 data points per degree) 
and, subsequently, curved mesh2s (following the curvature of Earth's 
surface) from these heightfields.

But whatever I try, all I get is an empty black scene... I tried 
tweaking the distance of the sun (Earth's center is at the origin), the 
illumination direction, correctly applying rotations of mesh2, camera 
position and camera direction, but no effect at all.

The scene should show a bird's view of the Tristan da Cunha archipelago 
in the southern Atlantic Ocean from about 10000 metres (currently only 
the bare relief with a simple green texture, no ocean or realistic 
satellite mosaic texture yet)...

Here is the code:

// Begin of code

#include "functions.inc"

#declare sf=0.001; // scaling factor to avoid epsilon problems

#declare os=0; // 0: Linux, 1: Windows
#switch (os)
   #case (0)
     #declare path="";
   #break
   #case (1)
     #declare path="../SRTM/png_patched/";
   #break
#end

global_settings
{
   assumed_gamma 2
}

#declare xdim=3601;
#declare ydim=3601;

#declare deadsea=422;
#declare everest=8848;
#declare rng=deadsea+everest;
#declare rd=6378140;

#declare latstart=-37;   // meshes are calculated from
#declare longstart=-13;  // the northwestern to southeastern corner of 
the original DEM tile

#declare res=3601;

#declare map=
pigment
{
   image_map
   {
     png concat(path, "s38w013_corrected.png")
   }
}

#declare Cam_Azi=-89.99999;
#declare Cam_Dir=0;
#declare Cam_Lat=-37.5;
#declare Cam_Long=-12.5;
#declare Cam_Height=10000;

#declare Earth_Pos=0;
#declare Earth_Tilt=0; // 23.439281;
#declare Earth_Rot=0;

#declare Earth_Slice=
mesh2
{
   vertex_vectors
   {
     xdim*ydim
     #declare row=0;
     #while (row<ydim)
       #declare col=0;
       #while (col<xdim)
         #declare clrvect=eval_pigment(map, <1/(xdim*2)+col/xdim, 
1-(1/(ydim*2)+row/ydim), 1>);
         #declare hval=clrvect.red*256+clrvect.green;
         #declare hval=-deadsea+rng/65535*hval;
 
rd+hval*<sin(radians(-longstart-col/xdim))*cos(radians(latstart-row/ydim)),
                  sin(radians(latstart-row/ydim)), 
cos(radians(-longstart-col/xdim))*cos(radians(latstart-row/ydim))>*sf
         #if (!(row=ydim-1 & col=xdim-1)) // no comma after last vector
           ,
         #end
         #declare col=col+1;
       #end
       #declare row=row+1;
     #end
   }
   face_indices
   {
     (xdim-1)*(ydim-1)*2
     #declare r=0;
     #while (r<ydim-1)
       #declare c=0;
       #while (c<xdim-1)
         <r*xdim+c, r*xdim+c+1, (r+1)*xdim+c>,
         <r*xdim+c+1, (r+1)*xdim+c+1, (r+1)*xdim+c>
         #if (!(r=ydim-2 & c=xdim-2)) // no comma after last vector
           ,
         #end
         #declare c=c+1;
       #end
       #declare r=r+1;
     #end
   }
   texture
   {
     pigment { color rgb <0, 0.8, 0> }
     finish { ambient 0.1 diffuse 1 brilliance 0.4 }
   }
   double_illuminate
}



#declare Cam_surfpos=trace(Earth_Slice, Earth_Pos, 
2*rd*<sin(radians(-Cam_Long))*cos(radians(Cam_Lat)), 
sin(radians(Cam_Lat)), cos(radians(-Cam_Long))*cos(radians(Cam_Lat))>);
#declare Cam_Pos=Cam_surfpos+vnormalize(Cam_surfpos)*Cam_Height;
#declare Cam_Pos=vrotate(Cam_Pos, <0, Earth_Rot, 0>);
#declare Cam_Pos=vrotate(Cam_Pos, <Earth_Tilt, 0, 0>);
#declare Cam_Look=<sin(radians(Cam_Dir))*cos(radians(Cam_Azi)), 
sin(radians(Cam_Azi)), cos(radians(Cam_Dir))*cos(radians(Cam_Azi))>;
#declare Cam_Look=vrotate(Cam_Look, <90-Cam_Lat, -Cam_Long, 0>);
#declare Cam_Look=vrotate(Cam_Look, <0, Earth_Rot, 0>);
#declare Cam_Look=vrotate(Cam_Look, <Earth_Tilt, 0, 0>);
#declare Cam_Look=Cam_Pos+Cam_Look;
#declare Cam_Sky=<0, 1, 0>;
#declare Cam_Sky=vrotate(Cam_Sky, <90-Cam_Lat, -Cam_Long, 0>);
#declare Cam_Sky=vrotate(Cam_Sky, <0, Earth_Rot, 0>);
#declare Cam_Sky=vrotate(Cam_Sky, <Earth_Tilt, 0, 0>);


object
{
   Earth_Slice
   rotate <Earth_Tilt, 0, 0>
   rotate <0, Earth_Rot, 0>
}


/* sphere
{
   0, rd
   texture
   {
     pigment { color rgb <0, 0, 0.4> }
     finish { ambient 0.1 diffuse 1 brilliance 0.6 }
   }
} */


camera
{
   location Cam_Pos*sf
   look_at Cam_Look*sf
   sky Cam_Sky
   angle 40
}

/* camera
{
   location <20000000, -20000000, 20000000>*sf
   look_at 0
   angle 60
} */


light_source
{
   <149600000000, 0, 0>*sf*sf
   color rgb 1
}

// end of code

I also attached the heightfield generated from the original ASTER 
GeoTIFF tile.

...and I thought I could come up with a surprise rendering of Tristan da 
Cunha as an introduction to POVEarth... but, alas, I'm no Christoph 
Hormann, so probably the whole thing is several orders of magnitude too 
ambitious for me. I should content myself with pixeling nice little flat 
heightfields and placing a few trees and buildings on them...

See you in Khyberspace!

Yadgar


Post a reply to this message


Attachments:
Download 's38w013_corrected.png' (253 KB)

Preview of image 's38w013_corrected.png'
s38w013_corrected.png


 

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.