Descriptions and Examples for the POV-Ray raytracer
by Friedrich A. Lohmüller
Deutsch
Italiano Italiano
Français français

Home
- POV-Ray Tutorial

- Realistic Skies
    - A Realistic Sky
    - Partly Cloudy Sky
    - Layers of Clouds
    - Stacked planes clouds
    - Shadow Casting
    - Massiv media clouds
    - Sunset Sky
    - Starry Skies
    - Skydomes + skymaps
   > Skyboxes + cubemaps
    - HDRI environment

    - Download
 
                                                   

How to create Realistic Skies with POV-Ray

Overview | 1 | 2 | 3 | 4 | 5 | 6 | 7.0 | 7.1 | 8 | 9 | 10

Cubic Environment Mapping
A Skybox with cube mapping:

This is another method of the environment mapping technique, also called cubic environment mapping or panorama cube mapping.
It's a common method used often in 3D games.
A skybox is a big cube with an 360° image of a sky and a ground ("skymap") mapped on the inside of this cube, with a 90°x90° view on each face of the cube. This method of environment mapping avoids the problem of the extrem distortions at the poles of a sphere with spherical mapping.
A freeware program to display and examine the Skybox Environment is the SkyboxViewer by Gerd Platl.

A Skyboy can be realizised in POV-Ray by uv_mapping of an image_map on a box.
We can use uv_mapping for mapping a texture in the XY plane from <0,0> to <1,1> to the surface of a box. The image is wrapped around the box, as shown in opposite images.
For using a 360° panoramic photo or image as a skymap with a skybox (with POV-Ray 3.6/3.7) we need to correct the gamma of the image/photo with the following macro:

// Macro for the adjustment of images
// for image_map with assumed_gamma = 1.0 ;
#macro Correct_Pigment_Gamma(Orig_Pig, New_G)
  #local Correct_Pig_fn =
      function{ pigment {Orig_Pig} }
  pigment{ average pigment_map{
   [function{ pow(Correct_Pig_fn(x,y,z).x, New_G)}
               color_map{[0 rgb 0][1 rgb<3,0,0>]}]
   [function{ pow(Correct_Pig_fn(x,y,z).y, New_G)}
               color_map{[0 rgb 0][1 rgb<0,3,0>]}]
   [function{ pow(Correct_Pig_fn(x,y,z).z, New_G)}
               color_map{[0 rgb 0][1 rgb<0,0,3>]}]
   }}
#end //
// "image_map" gamma corrected:
//    Correct_Pigment_Gamma(
//    pigment{ image_map{ jpeg "colors.jpg"}}
//    , Correct_Gamma)
//------------------------------------------------

box{ <-1, -1, -1>,< 1, 1, 1>
 texture{ uv_mapping
   Correct_Pigment_Gamma( // gamma correction
     pigment{
     image_map{ jpeg "Cubemap_2_2048x1536.jpg"
                map_type 0    // planar
                interpolate 2 // bilinear
                once //
              } //  end of image_map
    } // end of pigment
    , 2.2) //, New_Gamma
    finish { ambient 1 diffuse 0 }
 } // end of texture
scale 10000
} // end of skybox --------------------

Sky_map
A 360° panorama cube map
for cubic mapping on a POV-Ray box.
box uv_mapping sequence
Sequence of how a texture
in the XY plane from <0,0> to <1,1>
is wrapped around the box in POV-Ray.
Sample scene skymap
Cube map wrapping around a box.
// uv_mapping for box - POV-Ray syntax
box{ <-1,-1,1>,<1,1,1>
     texture{ uv_mapping  pigment{ ... }
              uv_mapping  normal { ... }
              uv_mapping  finish { ... }
            } // end texture
     scale 1
     rotate<0,0,0>
}//--------------------
uv_mapping syntay for a box in POV-Ray
Cubemap_2_inside_1.jpg
Skymap mapped on a box in POV-Ray
Cubemap_2_inside.gif 499kB
Animated 360° panorama with a skybox.
Description of this scenery for POV-Ray (not animated)
Cubemap_2_inside_1.txt or Cubemap_2_inside_1.pov

Download of the according cubic map in 2048x1536 pixel (768 kB)
here: Cubemap_2_2048x1536.jpg

Overview | 1 | 2 | 3 | 4 | 5 | 6 | 7.0 | 7.1 | 8 | 9 | 10

top

© Friedrich A. Lohmüller, 2013
homepage:http://www.f-lohmueller.de
 
Visitors:
(since May-1999)
Thanks for your visit!