Login / Register

     

I will buy Megaterrain 3ds max plug-in...

Results

Latest News

Home arrow Documentation arrow Megatexture Constructor

Megatexture Constructor

Sorry, the documentation is not finished yet.

Creating a terrain and importing data.

1. Creating a new empty terrain.
1.1. Creating a height-field.
1.2. Creating an indices and a weights megatextures.
1.3. Creating a detail texture.
1.4. Generating a diffuse megatexture.
2. Importing a terrain.
2.1. Importing a height-field.
2.2. Blend operations and blend masks.

2.3. Importing an index map.
2.4. Importing a diffuse map.

1. Creating a new empty terrain.

The Mega Terrain SDK contains two tools with almost identical functionality for working with a terrain:

  • gmtc.exe - GUI tool,
  • mtc.exe - command prompt tool.

You can use any tool you wish. To create an empty terrain you should make the following steps:

  • Create a height-field mega texture.
  • Create a weights mega texture and an indices mega texture.
  • Create a detail texture and set path to it.
  • Generate a diffuse mega texture.

1.1. Creating a height-field.

Using GUI tool

Run gmtc tool. Select the menu item "File -> New..." The following dialog will appear:

gmtc_pic1

File - mega texture file name. For example, mylandscape_h.mgt.
Type - mega texture type. Select height map here.
Size - mega texture size. Must be greater than InitDesc.StackSize value (see MegaTerrain SDK doc).
Meters / Pixel - height-field horizontal resolution. Recommended values for the first person shooter games is 0.5 - 2.0 meters per pixel.
Initial Value - initial terrain height in meters.
Minimum/Maximum Altitude - minimum and maximum landscape altitudes in meters. Values which are out of this range will be clamped. Height-field texture has 16 bits per pixel, it is not very much, so the smaller values you use, the better precision you get. Precision for the default values (minimum = -121.5 m, maximum = 2500 m) is 0.04 m ((121.5 + 2500) / 65536 = 0.04).

When all parameters are set, press OK to create the height-field mega texture.

Using command prompt tool

mtc.exe -megatex mylandscape_h.mgt -op create -createparams 0 2048 1.0 0 -121 2500

1.2. Creating an indices and a weights megatextures.

NOTE: Indices and weights megatextures are not supported by Megaterrain 3ds max plug-in. These megatextures can only be used for diffuse megatexture generation.

A texture of indices contains numbers of the detail textures used on the terrain. The format of the texture is R8G8B8A8, so there are four layers at every point. Weights of the layers are determined by the weights mega texture.

Using GUI tool

Run gmtc tool. Select the menu item "File -> New..." Set the following values:

File - mylandscape_i.mgt (the file name must end on "_i.mgt", otherwise the tool will not work correctly)
Type - Index Map
Size - must be equal to the size of the height-field texture
Meters / Pixel - must be equal to the meters/pixel value of the height-field texture
Initial Value - 0
Minimum/Maximum Altitude - these values are ignored (used only for height-fields)

Press OK to create the indices mega texture.

Now you should make a weights mega texture. Press "File -> New..." again. Set Type to "Weight Map" and Name to "mylandscape_w.mgt". (The name must be the same as used for the texture of indices except for the ending which must be "_w.mgt".) Other parameters must be equal to the parameters used for the texture of indices.

Press OK to finish.

Using command prompt tool

mtc.exe -megatex mylandscape_i.mgt -op create -createparams 2 2048 1.0 0 -121 2500
mtc.exe -megatex mylandscape_w.mgt -op create -createparams 3 2048 1.0 0 -121 2500

1.3. Creating a detail texture.

NOTE: Detail textures are not supported by Megaterrain 3ds max plug-in.

If a camera is at large distance from a landscape, a surface color is determined by the diffuse mega texture. When it approaches to the surface, the color is a mix of a mega texture and a detail diffuse texture, which contains small elements like blades of grass, stones. The detail texture is mapped on area 3x3 meters. (This value can be changeg in megaterran.fx shader, see #define DETAIL_TEXTURE_SIZE_IN_METERS.) A format of the diffuse detail texture must be DXT5 (you can use alpha channel), a size must be equal to the value of InitDesc.DetailTexureSize> (see MegaTerrainSDK documentation). It is recommended to use 1024x1024 textures. If needed, you can also create a normal map for the detail texture. A normal map fromat must be ATI2N (alternate XY swizzle). You can use the ATI Compressonator to compress textures to these formats. For every detail texture you must also create a texture which will be used by the utility gmtc (mtc) for the mega diffuse texture generation. Its format must be DXT5 and size 1024x1024. Here is an example of such textures (you can find the original DDS images in the Megaterrain SDK):

grass_near
grass_far

The detail diffuse texture.
Image area is 3x3 meters.

The texture used instead the detail diffuse texture
during a mega diffuse texture generation.
Image area is 512x512 meters
(for landscape resolution 0.5 meters / pixel).

So you must create a pair of textures. After the textures are created, you must set path to it. A path to detail textures is stored in a mega texture of indices. This operation you can do using the gmtc utility or using MegaTerrain SDK.
Run gmtc, click the menu item "File->Open...", open the mega texture of indices. Then click "Utils -> Edit Texture Names". A table with four columns will appear:
gmtc_pic2

Column 1: Index of a detail texture. (I also call it "material index".)
Column 2: Path to a detail texture.
Column 3: Path to a normal map for detail texture.
Column 4: Path to a texture used by the mega diffuse texture generator.

You should know that these texture names are passed to the function IMegaTerrainSDKCallback::LoadImage() when required. Now fill the first row (material index = 1) with pathes to the pair of textures you created before. Press OK.

By default the mega texture of indices is filled with material index 0. You must fill the entire texture with index 1. You can use gmtc or mtc to do this.

Using GUI tool

Run gmtc, click the menu item "File->Open...", open the mega texture of indices. In the appeared window:

  • Set Import/Export Region to the entire mega texture;
  • Set Index to 1;
  • Set Blend Op to "Replace";
  • Set main operation to "Import index map".
gmtc_pic3

Press "DO!" and the mega texture will be filled with index 1 in a few seconds.

Using command prompt tool

mtc.exe -megatex mylandscape_i.mgt -op import_indexmap -rect 0 0 2048 2048 -index 1 -blendop replace

1.4. Generating a diffuse mega texture.

The last step you should make - create and render the diffuse mega texture. This is an easy step if you make everything right before :)

Using GUI tool

You must create the diffuse mega texture at first. Run gmtc tool. Select the menu item "File -> New..." Set the following values:

File - mylandscape_d.mgt
Type - Diffuse Map
Size - must be equal to the size of the height-field texture
Meters / Pixel - must be equal to the meters/pixel value of the height-field texture
Initial Value - 0
Minimum/Maximum Altitude - these values are ignored (used only for height-fields)

Press OK.

Now in the main window of Mega Texture Constructor select Render Diffuse Map. Press DO! If there are no errors, you should see the mega diffuse texture during generation (appeared window should not be black).

After the texture is rendered, you must generate mip maps for it and reindex it (reindexing reduces the size of mega textures). In the main window select Reindex and gen. mips and press DO!

Using command prompt tool

mtc.exe -megatex mylandscape_d.mgt -op create -createparams 1 2048 1.0 0 -121 2500
mtc.exe -megatex mylandscape_d.mgt -op gen_diffuse -gen_diffuse_params mylandscape_i.mgt mylandscape_w.mgt
mtc.exe -megatex mylandscape_d.mgt -op reindex

That is all! Your first mega terrain is ready :)

2. Importing a terrain.


2.1. Importing a height-field.

The Megaterrain Constructor supports only BT (Binary Terrain) 1.3 file format for height-field importing. Data type must be floating point with 4 bytes per pixel. You can read more about this format here .

Using GUI tool

Run gmtc, click the menu item "File->Open..." and open the height-field mega texture you created before. In the appeared window in the "File:" text box type a path to the BT file. Then set main operation to "Import Height Map" and press "DO!".

Using command prompt tool

 
Copyright (C) 2007-2008 Zulus&Fly | Privacy Policy | Powered by Elxis