-
Notifications
You must be signed in to change notification settings - Fork 11
cube map tools
those tools are a group of tools for working on cube maps.
all cube maps use 6 images, which are set-up as if you where inside a cube of which every face was one of the cube map textures. therefore cube maps don't depend on your position in the 3d environment. the only thing that varies a cube maps in-game is the orientation of your point of view.
there are two kinds of cube maps:
- environment maps: used for reflections, in doom3 you can see them in the glass panels of the game.
- sky box maps: used as the last layer of the sky. guess where you can find it in d3...
those two kinds of maps use the 6 images, all of the same resolution. but their naming convention as well as appearance is different, hence the need of tools in order to convert and create those cube maps.
the actual pictures of a cube map are TGA files, and share a common base name that associates them all as a cube map.
the 6 pictures besides the base name, have an addendum that defines their "position" in the cube, this added name defines what face of the cube that picture adheres to.
let's say we have a "sky" basename:
- sky_forward.tga - 0 degrees face (degrees in a relation of the same direction you can see in the map editor z prespective)
- sky_back.tga - 180 degrees
- sky_left.tga - 90 degrees
- sky_right.tga - 270 degrees
- sky_up.tga - self-explanatory
- sky_down.tga - self-expla. blah blah blah
with those images you get a convincing texture of a sky all around you
then referencing that base name in a in-game material you get the sky in the 3d level.
--- TODO add a simple sky box material as an example TODO ---
the 6 pictures use another naming convention which at the same time for reason unknown it doesn't follow all that well.
the 6 pictures are separated in two groups of three images "p" images and "n" images (positive and negative)
so for a base name of "env" this is the naming convention:
- env_px.tga
- env_py.tga
- env_pz.tga
- env_nx.tga
- env_ny.tga
- env_nz.tga
but here is the strange stuff: env_px.tga is not the same face of the cube map as sky_forward.tga in fact none of the images correspond. this is the order:
- _nx --> _forward
- _py --> _back
- _ny --> _left
- _pz --> _right
- _nz --> _up
- _px --> _down
not only this both systems are a order of transforms apart from one another. this means that the same transforms can be applied in between the two:
- _nx = _forward rotated 90º clockwise and x flipped
- _py = _back y flipped, rotated 90º clockwise, x flipped and y flipped again
- _ny = _left y flipped
- _pz = _right x flipped
- _nz = _up rotated 90º clockwise and x flipped
- _px = _down rotated 90º clockwise and x flipped
the reason is unknown.
but if we want to use them we should apply such transforms on the images.
--- TODO add a simple environment map material as an example TODO ---
how do we acquire the cube maps then, is a mater of placing a virtual camera facing north, south... with a 90º fov and taking a tga screen-shot per position. if we do a square image we then get all the 6 images of a cube map.
in order to do so, we have the command envShot
(which creates environment maps as it's name implies)
envShot <baseName> <size>
envShot cubemap 512
will immediately pause the game and will create a set of 6 environment map textures with the base-name "cubemap" and with a size of 512*512 squared image then the game will resume as normal
with this we can create a new sky box map with the envToSky
command, which will change the names and apply the transforms accordingly
envToSky <baseName>
envToSky cubemap
will search the environment map textures with the base-name "cubemap" in the "env" folder on the fs_game folder. and will create the appropriate files for a sky map in the "skymap/ñçñçñç/" folder where "ñçñçñç" will be the base name you entered in the command.
so a "cubemap" base-named sky box textures will be created within a "cubemap" named directory, within a "skybox" directory on the fs_game directory
also we have a skyToEnv
command which will make the exact opposite
skyToEnv <baseName>
skyToEnv cubemap
will search a sky box map with the base-name "cubemap" within the "skybox" folder on the fs_game folder, and will convert it to the appropriate files for a environment map in the "env/ñçñçñç/" folder where "ñçñçñç" will be the base name you entered in the command.
so a "cubemap" base-named environment map textures will be created within a "cubemap" named directory, within a "env" directory on the fs_game directory
-
envShot
creates a 7th image named "_wrong" which is an actual failure of the process, the reasons for the failure remain unknown. you can erase the image although it won't interfere on the transforming commands processes. -
envShot
requires that the size entered in the command to remain under the smallest size of the desktop resolution you're using. in case of not doing so, those parts of the image that are out of the desktop space won't be rendered. originally this was averted by using a tiling renderer solution that currently seems to fail in BFG current implementation, this is most possibly due the heavily reworked renderer in BFG, in fact you can take screen-shots with a virtual resolution different than the one you're currently using, but the resulting screen-shots come out distorted. - keep in mind that
envShot
uses the player camera view, so if you don't want the weapon that currently the player is holding as well as the flash-light in the cube map you would be better off hiding them out as well a hide off the hud, you can do it with:g_showHud 0
and --TODO find the damn command to hide the weapon TODO--