Texture Importer

From C4 Engine Wiki

Jump to: navigation, search

Texture maps used by the C4 Engine have the .tex file extension. These texture map resources are created by importing texture images from a subdirectory of the Import directory using the Texture Importer tool.

The Texture Importer tool supports .tga files, which may be in 8-bit grayscale, 16-bit color, 24-bit color, or 32-bit color format, with or without RLE compression.

To import a texture, either choose Import Texture from the C4 menu or invoke the itexture [name] command in the Command Console. If the menu command is chosen, or the name is omitted from the console command, then the Texture Importer tool will open an Import Texture dialog that lets you select a .tga file from the Import directory. After selecting an image file to import, the Import dialog is opened with the default settings shown in the following figure. These default settings are usually appropriate for ordinary color texture maps.

Image:itexture.png


Texture Format

Setting

Description

Texture type

Selects the OpenGL texture target for this texture map. It can be one of the following values.

  • 2D An ordinary 2D texture whose coordinates lie in the range [0, 1] in both dimensions. The width and height of a 2D texture must be a power of two.
  • RECT A rectangle texture whose coordinates lie in the range [0, width] and [0, height]. The width and height do not need to be a power of two. The rectangle texture type should not be used for texture maps that are to be used in a 3D setting because they will adversely affect performance when minified. Rectangle textures are primary used for things like user interface images that appear in a 2D setting.
  • CUBE A cube map texture. See below.

Image format

Selects the output pixel format for this texture map. It can be one of the following values.

  • RGBA Color The image has four channels: red, green, blue, and alpha.
  • Luminance Alpha The image has two channels: grayscale luminance and alpha.
  • Luminance The image has one grayscale channel, and the alpha is always interpreted to be the maximum value.
  • Intensity The image has one grayscale channel, and the alpha is always interpreted to be equal to the gray value.

Alpha channel

Specifies what kind of information is stored in the alpha channel of the texture. It can be one of the following values. (If alpha channel information is specified, then the TGA file being imported must use a 32-bit format.)

  • None There is no information stored in the alpha channel.
  • Transparency The alpha channel contains transparency information.
  • Gloss The alpha channel contains a gloss map. Whenever a texture containing a gloss map in the alpha channel is used in a material, any specularity, environment map, or reflection term is modulated by the gloss map.
  • Opacity The alpha channel contains an opacity map. Whenever a texture containing an opacity map in the alpha channel is used in a material, the opacity is used to linearly interpolate between the diffuse term and the refraction term.
  • Glow The alpha channel contains glow intensity values that are used by the glow post-processing effect. This should only be used for emission maps.
  • Occlusion The alpha channel will contain ambient occlusion information. This can be a precomputed channel, or it can be generated when the texture is imported. See the description of the “Calculate ambient occlusion in alpha” box below.
  • Parallax The alpha channel of the import texture contains a height map from which parallax mapping information should be calculated. This can only be selected by checking the “Generate parallax data” box, and in this case, all four channels of the import texture should contain the same values. If the alpha channel of a normal map in a material contains parallax information, the parallax mapping is applied during all rendering passes.

S wrap mode / T wrap mode

Specifies what wrap modes to apply to the texture map. They can each be one of the following values.

  • Repeat The texture is addressed using the GL_REPEAT wrap mode.
  • Clamp The texture is addressed using the GL_CLAMP_TO_EDGE wrap mode. If this mode is not available, the GL_CLAMP is used instead.
  • Clamp to Border The texture is addressed using the GL_CLAMP_TO_BORDER wrap mode.
  • Mirror Repeat The texture is addressed using the GL_MIRRORED_REPEAT wrap mode.
  • Mirror Clamp The texture is addressed using the GL_MIRROR_CLAMP_TO_EDGE wrap mode.
  • Mirror Clamp to Border The texture is addressed using the GL_MIRROR_CLAMP_TO_BORDER wrap mode.

Use block compression

The output texture is stored in a hardware-recognized compression format. This should be turned on for almost all texture maps for best performance and memory usage. (This setting is ignored if the image format is not RGBA Color.)


Texture Flags

Setting

Description

Disable filtering

No filtering is applied to this texture map, and point sampling is used instead.

Disable anisotropic filtering

Anisotropic filtering is disabled for this texture map, but ordinary bilinear or trilinear filtering is still applied.

Require high-resolution rendering

The texture map is always rendered using the highest resolution available, even if the user has selected a lower-quality option in the Graphics Settings dialog.


Map/Channel Generation

Setting

Description

Calculate normal map

The import texture is treated as a height map from which a normal map should be calculated. Each height is multiplied by the value specified in the “Height map scale” field and used to determine the normal vector at each pixel.

Generate parallax data

When checked in addition to “Calculate normal map”, the height in the alpha channel is converted into special parallax data used by the engine. The same height map must be stored in all four channels of the import texture.

Generate horizon maps

When checked in addition to “Calculate normal map”, two additional textures are generated that contain horizon map data. These textures have the same name as the normal map, but with the suffixes -h1 and -h2. Horizon maps are applied to a material when the “Enable horizon mapping” box is checked in the Material Manager.

Calculate ambient occlusion in alpha

The heights stored in the alpha channel are scaled by the value specified in the “Height map scale” field and used to calculate an ambient occlusion factor that is applied in the ambient rendering pass.

Height map scale

Specifies a scale that is applied to all height values. A scale factor of 1.0 corresponds to the width of a single texel in the import texture.

Height map channel

Selects a channel to be used as the source of the height map for all calculations.

In order to access all features of the engine, normal maps should be created by the C4 texture importer, not by external programs. You can still use normal maps generated outside C4, but if you do, then you can't have associated parallax maps, horizon maps, or ambient occlusion maps. External normal maps can still be block compressed, but you must check the “Treat RGB channels as vector” box.


Options

Setting

Description

Output file name

Specifies the name of the texture file that will be created. (It should not include the extension.) This usually does not need to be changed from the default setting.

Calculate mipmap levels

All mipmap levels for this texture are calculated and stored in the texture resource. Turning this off for textures that are used in a 3D environment can have a negative effect on performance.

Bleed colors for alpha test

Causes texels that would fail the alpha test to pick up the color of the nearest texel that passes the alpha test. This process helps remove borders that can appear when alpha-tested textures are rendered. When this setting is checked, the alpha values in lower-resolution mipmaps are also boosted to prevent fade-out of alpha-tested geometries.

Treat RGB channels as vector

Mipmaps are calculated for vector data instead of color data. This is useful if you're importing a precomputed normal map as opposed to calculating a normal map from a height field. This box must be checked in order to get block compression for an externally generated normal map.

Invert green channel

The green channel of the import texture image is inverted. This is useful for changing handedness in externally generated normal maps.

Scale texture to half resolution

The import texture image is reduced to half size in each direction before being processed.

Scale horizon maps to half resolution

Horizon maps are generated from an import texture image that has been reduced to half size in each direction. Using this option can usually save a significant amount of memory without a noticeable reduction in rendering quality. (If “Scale texture to half resolution” is also checked, then both scales are applied, so horizon maps are only one-quarter the size in each direction.)

Flip image vertically

The import texture image is flipped in the vertical direction before being processed.

Remember settings

Generates a .cfg file in the directory containing the import texture that will be recognized the next time the texture is imported and used to populate the Import Texture dialog with the previous settings.


Skybox Haze

Setting

Description

Haze color

When checked, the haze color is applied at the bottom of the texture image with the appropriate warping for use as a skybox texture.

Haze elevation

Specifies the relative height to which the haze extends above the horizon. (Ignored if “Haze color” is not checked.)


Cursor Data

Setting

Description

Image center X / Image center Y

If importing a cursor texture, these settings specify the coordinates, in pixels, where the center, or “hot spot”, of the cursor is located.


Cube Maps

A cube map can be imported by creating a TGA file that is six times as tall as it is wide. The width must be a power of two, and each sixth of the image represents one face of the cube. As shown in the image to the right, the order of faces is positive x, negative x, positive y, negative y, positive z, and finally negative z. Each face must have the correct orientation in order for the cube map to work properly, and these are shown in the figure. The z axis always represents the up direction, and the direction specified in the center of each face represents the axis that points into the image.



Command Line

The itexture command can take parameters corresponding to all of the settings in the texture import dialog. The general form of this command is as follows.

itexture name params

If any parameters are specified on the command line, then the import dialog is not displayed. This facilitates batch texture importing by allowing itexture commands to be executed from a .cfg file.

The parameters accepted by the itexture command are listed in the following table. Multiple parameters should be separated by a space. Any unrecognized parameters are ignored.

Parameter

Description

-o name

The name of the output file is given by name. (The extension should not be included in the file name.) By default, the output path is the same as the input path, except that it's in the Data directory instead of the Import directory.

-type id

The texture type is given by id. The value of id must be 2D, RECT, or CUBE. The default is 2D.

-format id

The image format is given by id. Accepted values are RGBA, LMAL, LUMI, and INTS. The default is RGBA.

-alpha id

The alpha channel data type is given by id. Accepted values are ALFA, GLOS, OPAC, GLOW, and OCCL. By default, the alpha channel is considered empty.

-swrap id

The S wrap mode is given by id. Accepted values are REPT, CLMP, CBDR, MRPT, MCLP, and MCBD. The default is REPT.

-twrap id

The T wrap mode is given by id. Accepted values are the same as for the S wrap mode. The default is REPT.

-compress

Block compression is applied.

-nofilter

Disable filtering.

-noaniso

Disable anisotropic filtering.

-highres

Require high-resolution rendering.

-normal

Calculate normal map.

-parallax

Generate parallax data.

-horizon

Generate horizon maps.

-occlusion

Calculate ambient occlusion in alpha.

-scale value

Set the height map scale to value. The default is 8.0.

-height channel

Get the height map from channel, which must be 0–3, representing (in order) red, green, blue, or alpha. The default is 0 (red channel).

-nomipmaps

Do not calculate mipmap levels.

-bleed

Bleed colors for alpha test.

-vector

Treat RGB channels as vector.

-invgreen

Invert green channel.

-half

Scale texture to half resolution.

-halfhorizon

Scale horizon maps to half resolution.

-flip

Flip image vertically.

-haze elevation red green blue

Apply skybox haze using the color given by the floating-point values red, green, and blue and the elevation given by elevation (in the range [1,255]).

-x coord

Set the cursor center x coordinate to coord.

-y coord

Set the cursor center y coordinate to coord.


See Also