POVray Tips n' Tricks


I plan to collect any tricks here that I pick up while using POVray that you may find useful (if they're not already obvious, that is!) - if anyone has any more hints and tips of their own they'd like to add regarding any aspect of using POVray, then feel free to send them in and I'll put them up here!!

Filter Spheres
Planetary Atmospheres


Filter Spheres

If you're using any of the planetary maps found here or anywhere else on the Net, you'll notice there's a lot of plain greyscale maps around - in an ideal world, everything should be in glorious 24-bit colour, but this isn't an ideal world ;). But all is not lost. You can generally 'colourise' an entire map quite easily using a Filter Sphere, which is a transparent sphere placed over the original map that filters incoming light and tints the surface below a certain colour. While this may be a rather simplistic way of colouring a surface, I find it a bit easier than messing around with the colour palettes of the maps themselves! And you can also use your own pigment maps and turbulence settings and what-have-you on the filter sphere too, if you like. You can use Filter Spheres to make Mars redder, Uranus greener, or Mercury a brown colour if you like.

To make a Filter Sphere, all you need to do is place a transparent coloured sphere over an existing sphere (on which we already have a planetary image_map projected). The Filter Sphere need only be slightly larger than the existing sphere - the exact amount makes no difference - one significant figure difference in radii is all that you need. The Filter Sphere needs to be of the colour that you want to tint the underlying sphere, and must be made transparent using the 'filter' function if the light is to be tinted at all.

For example, without a Filter Sphere, the planet Mercury looks bland and pale grey (because the basic image_map provided here is greyscale) - but what if I wanted to change the colour to something else, say sepia brown? I've defined a colour called 'Mercury', and can apply this to the whole planet using a 'Mercury' filter sphere, as shown below:


//declare Mercury colour (sepia brown)
#declare Mercury = color red 0.854 green 0.713 blue 0.695

// create Mercury image_map sphere 
sphere
{  <0, 0, 0>, 3398
   pigment {image_map {tga "mercury.tga" map_type 1 interpolate 2}}
   finish {ambient 0 diffuse 1 specular 0}
}

//tint the image map using the Mercury colour defined earlier and an overlying filter sphere
sphere
{  <0, 0, 0>, 3399
pigment {color Mercury*1.1 filter 0.95}
}

There's a couple of things to note here - one is that I've used a filter value of 0.95 - a value of 1.0 would be a perfect filter, but any high (0.80+) value will do - just remember though that the lower the filter value, the harder it is to see the underlying image_map sphere as the filter sphere is becoming more opaque. So you can use the filter value to affect the brightness of the underlying surface, which may come in useful sometimes.

The other thing to notice is that I've got a multiplier tacked onto the Mercury colour. If you're not familiar with this, it's quite a handy way of easily controlling the rgb values of the colour - the multiplier (1.1 in this case) is applied to all the rgb values to decrease or increase the filter sphere colour brightness - the lower (or higher) the multiplier, the harder it will be to see the underlying sphere as the light is passing through a progressively darker (or brighter) filter. In this case, it turns the Mercury colour (rgb <0.854, 0.713, 0.695>) into rgb <0.9394, 0.7843, 0.7645>, so it can be a quick and handy way to control the brightness. Here's the difference it makes to a rendering:


Mercury without a Filter Sphere

Mercury with a Filter Sphere



Planetary Atmospheres (devised by Galen Raben).

Galen Raben has managed to get a realistic-looking atmospheric haze effect around a planet in a rendering by using a halo - the code (as a #declare) is shown below. It's a bit fiddly to use correctly, but the results are worth it! Note: This only works with POVRay 3.02 - it is not compatible with the new atmosphere system in POV 3.1

#declare Atmosphere =
sphere {
  <0, 0, 0> 1						// don't change this!
  pigment {color rgbt <1, 1, 1, 1>}			// don't change this!
  halo {
    emitting
    spherical_mapping
    linear
    frequency 8
    color_map {						// * explained below
      [0.0  color rgbt <0.2, 0.2, 0.3, 1>]	
      [1.0  color rgbt <0.45, 0.45, 0.55, -1>]	
    }
    samples 10
  }
  hollow
  scale 7000						// ** explained below
}


*: The color_map used here should represent the colour of the planetary atmosphere - the colours used should look the same, but the 1.0 end of the color_map should be brighter than the 0.0 end - so you'll need a blue-ish atmosphere for Earth, a pink-ish one for Mars, and so on. If you were to render this code on its own, you would see a series of concentric spherical 'glowing shells', the outermost of which is your atmosphere.
Here are a few colour_maps that give appropriate colours for some of the planets in the Solar System:

//Earth/Cytherea/Blue Mars/Neptune/(Uranus?) atmosphere (blue-ish)
    color_map {
      [0.0  color rgbt <0.2, 0.2, 0.3, 1>]
      [1.0  color rgbt <0.45, 0.45, 0.55, -1>]
    }

//Mars(/Titan?) atmosphere (orange/reddish)
    color_map {
      [0.0  color rgbt <0.4, 0.2, 0.2, 1>]
      [1.0  color rgbt <0.65, 0.45, 0.45, -1>]
    }

//Jupiter/Saturn atmosphere (yellow-ish)
    color_map {
      [0.0  color rgbt <0.3, 0.2, 0.2, 1>]
      [1.0  color rgbt <0.55, 0.45, 0.45, -1>]
    }


**: The scale factor is very important - note that by default this code renders an atmosphere that is 1 unit in radius. To get the right effect for your planet, you have to scale the atmosphere up such that it is slightly larger than the planet itself. Bear in mind that you don't want the atmosphere to extend too far out from the planet's visible surface, otherwise it will look very unrealistic - I think a scale value of about 110% of the planet's radius is usually appropriate. If you're using a 1 POV unit = 1 km scale, the Earth Atmosphere scale factor should be 6900, Mars/Blue Mars should be 3650, and Cytherea/Venus should be 6500.


Implementing the atmosphere

To actually use the atmosphere, all you need to do is put it in the same place as the planet - this is best done using a union statement as shown below (of course, you can also manually translate the atmosphere in any way that you want to!). Note that you'll have to make sure the colour_map is appropriate for the planet you use in the scene! Personally, I prefer to scale the atmosphere in the declare statement rather than in the object statement, but you can do it either way - I don't think you can define the colour_map in the object statement though:

union {
sphere
{  <0, 0, 0>, 3393
pigment {image_map {tga "mars.tga" map_type 1 interpolate 2}}
finish {ambient 0 diffuse 1 specular 0}
}
//object {Atmosphere}
}


Using atmospheres in images

Atmospheres only really come into their own when you get very close to the planet (like in my 'Moonrise over Britain' image), but you can still put them to good use at larger distances. Of course, if you have a wide-angle view from millions of miles away you're not going to be able to separate the atmosphere from the planet itself - but at middle distances you can use it to simulate light scattering through the sunlit portion of the atmosphere and create a thin 'halo' that girdles the dark side of the planet. This is demonstrated in my Earthrise image, or around Jupiter in the Io image of the Galilean Suite).



Back to the Art Hub
Back to the EDG Title Page

Frame URL: http://www.evildrganymede.net/art/tips.htm
All material here is © the authors.