POV-Ray : Newsgroups : povray.binaries.images : Adding an alpha gradient to an image_map? : Re: Adding an alpha gradient to an image_map? Server Time
30 Jul 2024 08:18:11 EDT (-0400)
  Re: Adding an alpha gradient to an image_map?  
From: Jörg 'Yadgar' Bleimann
Date: 14 May 2012 13:49:21
Message: <4fb145a1@news.povray.org>
Hi(gh)!

On 14.05.2012 12:41, Tek wrote:
>
> It's possible to add an alpha gradient to an image map like this:
>
> pigment {
>      gradient y
>      pigment_pattern {
>          [0 image_map {<your image>  }]
>          [1 image_map {<your image>  transmit all 1 }]
>      }
> }
>
> So the gradient blends between opaque and transparent versions of the map.

I tried this, but got strangely distorted bitmaps with sharp boundaries 
between day and night texture (see attached image). Also, what was meant 
to be a rendering centered around North Pole turned out to show mostly 
North America...

Here is my code:

#declare sc=1000;

#declare bodies = array [81][12]
{
   {           0,     696000,       -1,      -1,	     7.25,     0, 
  0,             0,         0,       0.000009,  63.87,   286.125   }, 
//   0 - Sun
   {    57909100,       2439.7,     -1,      -1,      2.11,     7.005, 
  0.205630,     29.124,    48.331,   0.00059,   61.45,   281.01    }, 
//   1 - Mercury
   {   108208930,       6051.8,     -1,      -1,    177.36,     3.39471, 
0.0068,       54.85229,  76.67069, 0.00019,   67.16,   272.76    },  // 
   2 - Venus
   {   149597887.5,     6378.14,  6378.14, 6356.8,   23.439281, 0, 
  0.016710219, 114.20783,  -1,       0.0033528, 90,       90       } 
//   3 - Earth
[...]
}

#declare east=1;

#if (east)
   #declare Pos_Earth   = bodies[3][0]*<sin(radians(0)), 0, 
cos(radians(0))>; // eastern hemisphere in daylight
#else
   #declare Pos_Earth   = bodies[3][0]*<sin(radians(180)), 0, 
cos(radians(180))>; // western hemisphere in daylight
#end


#macro SetAxis(dec, ras)
   rotate <bodies[3][4]-(90-dec), 0, 0>
   rotate <0, 90-ras, 0>
#end


#declare T_Earth_Night =
texture
{
   pigment
   {
     image_map
     {
       png "solarsys/ev5826_land_ocean_ice_lights_8192.png"
       map_type 1
       interpolate 2
     }
     // scale <1, 1, 0.5>
   }
   finish
   {
     ambient 1
     diffuse 0
   }
}

#declare T_Earth_Day =
texture
{
   pigment
   {
     image_map
     {
       png "solarsys/ev11612_land_ocean_ice_8192_POV.png"
       map_type 1
       interpolate 2
     }
     // scale <1, 1, 0.5>
   }
   finish { F_Standard_Planetary_Surface }
}


union
{
   sphere // Earth, surface
   {
     0, 1
     texture
     {
       gradient z
       texture_map
       {
	[0    T_Earth_Day]
	[0.45    T_Earth_Day]
	[0.55 T_Earth_Night]
	[1    T_Earth_Night]
       }
       scale 2
       translate <0, 0, -1>
     }
     scale <bodies[3][1], bodies[3][2], bodies[3][3]>/sc
   }
   sphere // Earth, clouds
   {
     0, 1
     texture
     {
       pigment
       {
	image_map
	{
	  png "solarsys/cloud_combined_8192a_alpha.png"
	  map_type 1
	  interpolate 2
	}
       }
       finish { F_Standard_Planetary_Surface }
     }
     scale <bodies[3][1]+5, bodies[3][2]+5, bodies[3][3]+4.983270985>/sc
   }
   rotate -y*clock
   SetAxis(bodies[3][10], bodies[3][11])
   translate Pos_Earth/sc
}

     #declare long =0;
     #declare lat=90; // North Pole
     #declare long=-long-90; // adjusting longitude to PoV-Ray's 
rotation system
     #declare h=20000; // orbital height (unscaled kilometres)
     #declare camPos = Pos_Earth + vrotate ((6378.14 + h) * 
<sin(radians(long))*cos(radians(lat)), sin(radians(lat)), 
cos(radians(long))*cos(radians(lat))>, <bodies[3][4], 0, 0>);
     #declare camLook = Pos_Earth;
     #declare camAng = 40;

camera
{
   #if (cam = 5.8)
     sky camSky
   #end
   location camPos/sc
   look_at camLook/sc
   angle camAng
}

// end of code

See you in Khyberspace!

Yadgar


Post a reply to this message


Attachments:
Download 'povsolar.png' (305 KB)

Preview of image 'povsolar.png'
povsolar.png


 

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