Development Tips¶
Sky boxes¶
Ogre uses cubic textures for sky cubes. To create one, it is required to create 6 equally sized squared images that have to align seemlessly at their edges. Then create an Ogre material script with the following content:
material testskybox
{
technique
{
pass
{
lighting off
depth_write off
texture_unit
{
texture IMAGEBASENAME.jpg cubic
tex_address_mode clamp
}
}
}
}
Replace testskybox
with the name of the skybox; this is what will be used in the C++ code to refer to it. Replace IMAGEBASENAME.jpg
with the basename of the 6 sky cube images. Ogre automatically constructs the actual file names from this basename. Because our game uses the Z axis pointing upwards in order to accomodate Blender (rather than Ogre's default setting, which has the Y axis upwards), the file names map to the axes as follows:
Axis | Filename | Required offset from normal |
---|---|---|
X+ | IMAGEBASENAME_rt.jpg | 90° clockwise |
X- | IMAGEBASENAME_lf.jpg | 90° counter-clockwise |
Y+ | IMAGEBASENAME_up.jpg | 0° |
Y- | IMAGEBASENAME_dn.jpg | 180° |
Z+ | IMAGEBASENAME_bk.jpg | 0° |
Z- | IMAGEBASENAME_fr.jpg | 180° |
The Z- axis points below the horizon; in normal circumstances the player should not see this surface of the sky cube, because it is obfuscated by the ground. If the required offsets are not applied, the images appear rotated in the game. So, if you intend to use the same images for the Y+ axis and the X+ axis, rotate the one for the X+ axis 90° clockwise before exporting to the JPG file.
JPG as format is not required. Since I used actual photos of clouds, using JPG was just natural.
Updated by quintus over 3 years ago · 4 revisions