-
Notifications
You must be signed in to change notification settings - Fork 0
TerrainExporting
Obviously, this entire exercise would be pretty useless if there wasn't a way to save the terrain for use in other programs. Thankfully, there are a few ways you can do that.

| Option | Description |
|---|---|
| Max LOD Levels | The editor can automatically generate models with varying levels of detail for you. For the most part two or three should be fine, but you can have more if you want. Depending on your chunk size and reduction factor it may not actually generate this many. Each LOD will be saved as its own file. |
| LOD Reduction Factor | How much to reduce the detail in each LOD level by. This factor is the total amount of vertex data removed per level. A factor of 4x means that half of the points on the horizontal and vertical axes will be sampled, resulting in one quarter the data. |
| Smooth Normals | Whether or not to smooth the vertex normals when exporting. Not yet implemented. I'll probably go back to it some day. |
| Normal Threshold | Faces that are within at most this angle of each other will be smoothed. |
| Export All Faces | If disabled, faces below height z = 0 will not be included in the export. This may result in empty files, which are up to you to deal with. |
| Centered | Use this to set the world origin of exported models to the center of the terrain instead of the upper-left. |
| Export Scale | You can change the scale of the terrain when you export it to a file. The editor assumes one unit of world space corresponds to one meter (hence the stats in the General tab), but you may, for example, prefer something like 32 or 100 units of world space to correspond to one meter. Large scale factors on large terrains may result in floating point error far away from the world origin. |
| Chunk Size | In addition to multiple LODs, you can also split the terrain up into chunks. This allows you to only have to render the terrain near the player and not the entire game world, which can be of varying levels of importance in large game worlds. This works well with the LOD settings mentioned earlier. For small terrains you can choose to ignore this, but terrains larger than one square kilometer must be chunked. Like LODs, each chunk will be saved as its own file. |
| Add to Project | Someday I plan on integrating this with the rest of my game development tools, but that day is not today. |
| Use Y-up? | Some |
| Flip Vertical Texture Coordinate | Some |
| Vertex Format | This is kind of its own entire thing (see below). |
Currently, you are allowed to save terrain as a GameMaker model file (which I'm pretty sure I'm the only person who still uses even occasionally anymore), a Wavefront Object (a horrendous file format that is somehow still popular), or a raw vertex buffer (if you're planning on importing terrain directly into a GameMaker game, this is the only one you should even consider using). If you export a vertex buffer, you also get the pleasure of deciding which vertex attributes you want to export with it.
If you don't know what these are, only select Poisition, Normal, Texture, Color.
| Attribute | Description |
|---|---|
| Position | The 3D position; this one is required (3 x float32) |
| Normal | The normal vector for each vertex (3 x float32) |
| Texture | The texture coordinate for each vertex (2 x float32) |
| Color | The vertex color, plus alpha (4 x uint8) |
| Tangent | The tangent vector for each vertex (3 x float32) (not yet implemented) |
| Bitngent | The bitangent vector for each vertex (3 x float32) (not yet implemented) |
| Barycentric | The barycentric coordinate of each vertex (this essentially indexes each vertex in a triangle) |
There are also what I like to call "nonstandard attributes" that you can use. These contain the same data as the standard attributes, but are squeezed into less space (and consequently have less precision). For example, sometimes you don't need twelve entire bytes for a normal vector, and will happily settle for just four. This won't necessarily let you render your terrain faster, but it can reduce the amount of memory needed, which is sometimes nice.
| Attribute | Description |
|---|---|
| Small Normal | The normal vector for each vertex (3 x uint8, with an empty byte at the end). Interpret this as a color attribute in your shader. Each value will have a range of 0 through 1, so you will need to adjust accordingly. |
| Small Tangent | Same as the above, but for the tangent vector. Not yet implemented. |
| Small Bitangent | Same as the above, but for the bitangent vector. Not yet implemented. |
| Small Texcoord | The texture coordinate for each vertex (2 x uint8 with two empty bytes at the end). Interpret this as a color attribute in your shader. Each value will have a range of 0 through 1, which is what you usually want, but you will lose some precision. For terrains with a small number of textures, this should usually be fine. |
| Small Normal plus Palette | Same as Small Normal, but instead of an empty byte at the end (taking up the alpha channel of a color) it's the horizontal component of Small Texcoord. If you treat your terrain texture as a color palette that only uses the X axis of the image, you may find this useful. |
| Small Barycentric | You can probably guess what this is for, but I'll be honest, I totally forgot to implement it and I don't foresee many people using it so I don't know if I'm going to. |