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 -------------------- |
|
A 360° panorama cube map
for cubic mapping on a POV-Ray box.
Sequence of how a texture
in the XY plane from <0,0> to <1,1>
is wrapped around the box in POV-Ray.
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
|