POV-Ray : Newsgroups : povray.binaries.images : POVEarth: I just don't get it... Server Time
1 Nov 2024 10:17:42 EDT (-0400)
  POVEarth: I just don't get it... (Message 1 to 7 of 7)  
From: Jörg 'Yadgar' Bleimann
Subject: POVEarth: I just don't get it...
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


 

From: Christian Froeschlin
Subject: Re: POVEarth: I just don't get it...
Date: 28 Jun 2013 18:10:01
Message: <51ce09b9$1@news.povray.org>


> 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.

start small ... you seem to assume that the curved mesh itself
is correct which is a very big assumption for a first test with
such a complicated definition. Make a test scene where you render
some spheres at calculated vertex positions for a small subset of
coordinates to get an overview of your geometry.

And then start with a reasonable test sphere of maybe radius 100
for sea level and add elevations between 0.0 and 1.0 for testing.

Also, rendering a planet as high resolution spherical mesh
is admittedly cool but probably overkill. The Earth is pretty
smooth - on scales where the curvature matters you don't really
need true elevated geometry. A sphere with normals might do
the trick just as well.


Post a reply to this message

From: Jörg 'Yadgar' Bleimann
Subject: Re: POVEarth: I just don't get it...
Date: 28 Jun 2013 18:35:12
Message: <51ce0fa0@news.povray.org>
On 29.06.2013 00:09, Christian Froeschlin wrote:

> start small ... you seem to assume that the curved mesh itself
> is correct which is a very big assumption for a first test with
> such a complicated definition. Make a test scene where you render
> some spheres at calculated vertex positions for a small subset of
> coordinates to get an overview of your geometry.
>
> And then start with a reasonable test sphere of maybe radius 100
> for sea level and add elevations between 0.0 and 1.0 for testing.

Does not work either... only the same black void!

>
> Also, rendering a planet as high resolution spherical mesh
> is admittedly cool but probably overkill. The Earth is pretty
> smooth - on scales where the curvature matters you don't really
> need true elevated geometry. A sphere with normals might do
> the trick just as well.

That's true, but I want to do animated flights at 5 to 10 kms over 
ground, with only those data tiles to be included which actually would 
be in the FOV of the camera... and landscapes would not be realistic if 
one could see let's say Mt. Everest from central Europe...

See you in Khyberspace!

Yadgar


Post a reply to this message

From: Jörg 'Yadgar' Bleimann
Subject: Re: POVEarth: I just don't get it...
Date: 29 Jun 2013 16:44:55
Message: <51cf4747@news.povray.org>
On 29.06.2013 00:09, Christian Froeschlin wrote:

>
>> 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.
>
> start small ... you seem to assume that the curved mesh itself
> is correct which is a very big assumption for a first test with
> such a complicated definition. Make a test scene where you render
> some spheres at calculated vertex positions for a small subset of
> coordinates to get an overview of your geometry.

The main problem seems to be that

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))>)

which probes for the mesh, always returns zero... why?

See you in Khyberspace!

Yadgar


Post a reply to this message

From: Alain
Subject: Re: POVEarth: I just don't get it...
Date: 29 Jun 2013 17:28:34
Message: <51cf5182$1@news.povray.org>

> On 29.06.2013 00:09, Christian Froeschlin wrote:

>>
>>> 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.
>>
>> start small ... you seem to assume that the curved mesh itself
>> is correct which is a very big assumption for a first test with
>> such a complicated definition. Make a test scene where you render
>> some spheres at calculated vertex positions for a small subset of
>> coordinates to get an overview of your geometry.
>
> The main problem seems to be that
>
> 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))>)
>
> which probes for the mesh, always returns zero... why?
>
> See you in Khyberspace!
>
> Yadgar

you have:
trace{Object, location, direction}

Apparently, you trace from the center of your Earth. Are you sure that 
your direction is actualy toward the slice you are using?
The lenght of the direction vector don't need to be large, you can 
remove the "2*rd*".

Maybe doing a test with the camera placed to see the inside of the slice.
Next, make a cylinder like this:
cylinder{Earth_Pos, 
2*rd*<sin(radians(-Cam_Long))*cos(radians(Cam_Lat)),sin(radians(Cam_Lat)), 
cos(radians(-Cam_Long))*cos(radians(Cam_Lat))>
,1
pigment{rgb<1,0,0>}finish{emission 1}
}

If that cylinder is not directed toward you slice, it mean that your 
math need reworking.

You may try this for your direction:
<sin(radians(Cam_Long)), sin(radians(Cam_Lat)),cos(radians(Cam_Long))>



Alain


Post a reply to this message

From: Cousin Ricky
Subject: Re: POVEarth: I just don't get it...
Date: 29 Jun 2013 18:35:01
Message: <web.51cf6018b26e8b56540235480@news.povray.org>
=?ISO-8859-1?Q?J=F6rg_=27Yadgar=27_Bleimann?= <yaz### [at] gmxde> wrote:
> The main problem seems to be that
>
> 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))>)
>
> which probes for the mesh, always returns zero... why?

Try adding a 4th parameter:

  #declare Norm = <0, 0, 0>; //dummy assignment
  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))>,
  Norm)

If Norm is <0, 0, 0> after the call to trace(), then the trace has missed the
object entirely.


Post a reply to this message

From: Jörg 'Yadgar' Bleimann
Subject: Re: POVEarth: I just don't get it...
Date: 30 Jun 2013 02:34:31
Message: <51cfd177$1@news.povray.org>
Hi(gh)!

On 30.06.2013 00:30, Cousin Ricky wrote:
> =?ISO-8859-1?Q?J=F6rg_=27Yadgar=27_Bleimann?=<yaz### [at] gmxde>  wrote:
>> The main problem seems to be that
>>
>> 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))>)
>>
>> which probes for the mesh, always returns zero... why?
>
> Try adding a 4th parameter:
>
>    #declare Norm =<0, 0, 0>; //dummy assignment
>    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))>,
>    Norm)
>
> If Norm is<0, 0, 0>  after the call to trace(), then the trace has missed the
> object entirely.

After setting the background to white for better visibility, I found out 
that I forget to put the two parts of the scaling factor for the vertex 
vectors in brackets - so the mesh2 ended up in a completely different 
location than defined by the geographical coordinates!

Originally, it was:

         rd+hval*<vertVect>

with rd being Earth's radius and hval the terrain elevation value gained 
from the pixel colour of the heightfield.

Of course it must be:

         (rd+hval)*<vertVect> !

Attached below is what I've got... still at a low test resolution, but 
the three main islands, Tristan da Cunha, Inaccessible and Nightingale, 
are clearly discernible!

Now let's go for a full-resolution view...

See you in Khyberspace!

Yadgar


Post a reply to this message


Attachments:
Download '2013-06-30 tristan da cunha, take 1.jpg' (16 KB)

Preview of image '2013-06-30 tristan da cunha, take 1.jpg'
2013-06-30 tristan da cunha, take 1.jpg


 

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